Linux常用命令简述--dirname与basename

 

dirname 获取父目录
basename 显示最后的目录名或文件名

1、dirname
[root@liang ~]# dirname /etc/httpd/
/etc

[root@liang ~]# dirname /etc/
/

[root@liang ~]# dirname /etc/httpd/conf/httpd.conf
/etc/httpd/conf


2、basename
[root@liang ~]# basename $PATH
tmp

[root@liang ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp

[root@liang ~]# basename $PATH
tmp

[root@liang ~]# basename /etc/httpd/conf/httpd.conf
httpd.conf

 

 

参考:

https://blog.51cto.com/2937761/2090137

 

posted @ 2019-08-22 19:30  anobscureretreat  阅读(177)  评论(0编辑  收藏  举报