Function: Remove the directory and suffix of the file
1. Remove the file path
1 basename /backup/jenkins/ci/script/release. SH . bak 2 Release. sh. bak
2. Remove the file suffix
1 basename /backup/jenkins/ci/script/release. SH . bak. bak 2 Release. SH 3 ls 4 Release. SH Release. SH . bak 5 [email protected]:~/ci/script$
3. Consider the number of suffixes
basename /backup/jenkins/ci/script/release. SH . Bak.old. Oldrelease . SH . Bak[email protected]: basename /backup/jenkins/ci/script/release. SH . Bak.old. old. Bak basename: Extra operand '. Bak'Try 'basename --help' for more information.
4. Abnormal suffix
1 basename AB b 2 A
5. Other
[Email protected]--printing parameters
$#--Number of printing parameters
$?—— The execution result of the last command/function, 0 for success, not 0 for failure
$!—— pid of the last background run process
$$--the ppid of the last background run process
basename usage in Linux