首页 > 系统服务 > 详细

linux命令 dirname

时间:2017-09-28 09:22:28      阅读:170      评论:0      收藏:0      [点我收藏+]

功能: 获取给定路径的目录部分

 

利用man 查看dirname的说明如下:

DESCRIPTION        Output each NAME with its last non-slash component and trailing slashes removed; if NAME contains no /‘s, output ‘.‘ (meaning the cur‐        rent directory).

       -z, --zero               end each output line with NUL, not newline

       --help display this help and exit

       --version               output version information and exit

 

例如:

 hbg@root:/$ dirname /usr/sbin/cron
/usr/sbin
hbg@root:/$ dirname /usr/sbin/
/usr
hbg@root:/$ dirname /usr/sbin
/usr

 

shell脚本中使用比较多的是 

cd `dirname $0`

命令。这个命令的含义是 返回这个脚本文件放置的目录,并可以根据这个目录来定位所要运行程序的相对位置(绝对位置除外)。

 

linux命令 dirname

原文:http://www.cnblogs.com/rohens-hbg/p/7604839.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!