作用:去掉文件的目录和后缀
1.去掉文件路径
jenkins@work:~/ci/script$ basename /backup/jenkins/ci/script/Release.sh.bak
Release.sh.bak
2.去掉文件后缀
jenkins@work:~/ci/script$ basename /backup/jenkins/ci/script/Release.sh.bak .bak
Release.sh
jenkins@work:~/ci/script$ ls
Release.sh Release.sh.bak
jenkins@work:~/ci/script$
3.考虑后缀数量
jenkins@work:~/ci/script$ basename /backup/jenkins/ci/script/Release.sh.bak.old .old
Release.sh.bak
jenkins@work:~/ci/script$ basename /backup/jenkins/ci/script/Release.sh.bak.old .old .bak
basename: extra operand `.bak'
Try `basename --help' for more information.
4.不正常的后缀
jenkins@work:~/ci/script$ basename ab b
a
5.其他
$@—— 打印参数
$#—— 打印参数个数
$?—— 最后一个命令/函数的执行结果,0为成功,非0失败
$!—— 最后一个后台运行进程的PID
$$—— 最后一个后台运行进程的PPID