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
参考: