以 make 文件为例:
file=/usr/bin/make
[root@CentOs7]# echo ${file%*/} /usr/bin/make [root@CentOs7]# echo ${file%%*/} /usr/bin/make [root@CentOs7]# echo ${file%%/*} [root@CentOs7]# echo ${file%/*} /usr/bin [root@CentOs7]# echo ${file#/*} usr/bin/make [root@CentOs7]# echo ${file##/*} [root@CentOs7]# echo ${file##*/} make [root@CentOs7]# echo ${file#*/} usr/bin/make
file=/usr/share/man/man1/make.1.gz
[root@CentOs7]# echo ${file%*/} /usr/share/man/man1/make.1.gz [root@CentOs7]# echo ${file%%*/} /usr/share/man/man1/make.1.gz [root@CentOs7]# echo ${file%%/*} [root@CentOs7]# echo ${file%/*} /usr/share/man/man1 [root@CentOs7]# echo ${file#/*} usr/share/man/man1/make.1.gz [root@CentOs7]# echo ${file##/*} [root@CentOs7]# echo ${file##*/} make.1.gz [root@CentOs7]# echo ${file#*/} usr/share/man/man1/make.1.gz
标签:shell,file%,后缀,echo,CentOs7,usr,file,Linux,root From: https://www.cnblogs.com/wutou/p/17153141.html