Shell获取文件的文件名和扩展名的例子
basename
example.
tar
.gz .
tar
.gz
# => example
FILE=
"example.tar.gz"
echo
"${FILE%%.*}"
# => example
echo
"${FILE%.*}"
# => example.tar
echo
"${FILE#*.}"
# => tar.gz
echo
"${FILE##*.}"
# => gz
basename
example.
tar
.gz .
tar
.gz
# => example
FILE=
"example.tar.gz"
echo
"${FILE%%.*}"
# => example
echo
"${FILE%.*}"
# => example.tar
echo
"${FILE#*.}"
# => tar.gz
echo
"${FILE##*.}"
# => gz