First, Introduction
1, dirname command to remove the non-directory part of the file name, delete the last "\" After the path, display the parent directory. Syntax: dirname [options] Parameter
2. The basename command is used to print the directory or the base name of the file, showing the last directory name or filename. Syntax: basename [options] Parameter
Ii. Examples of Use
1, DirName
[Email protected] ~]# dirname/etc/httpd/
/etc
[Email protected] ~]# dirname/etc/
/
[Email protected] ~]# dirname/etc/httpd/conf/httpd.conf
/etc/httpd/conf
2, basename
[Email protected] ~]# basename $PATH
Tmp
[Email protected] ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp
[Email protected] ~]# basename $PATH
Tmp
[Email protected] ~]# basename/etc/httpd/conf/httpd.conf
httpd.conf
Brief introduction to Linux common commands--dirname and basename