Removing everything but filename extension
This question already has an answer here:
Try this:
x=file.tar.sh
echo ${x##*.}
This will print sh
If you want to get tar.sh
, then:
echo ${x#*.}
Here *
matches any set of characters before the occurrence of .
上一篇: 用bash脚本获取文件扩展名
下一篇: 删除所有文件扩展名