Home Linux 获取文件名和后缀
Post
Cancel

Linux 获取文件名和后缀

举例说明

filename="this.is.a.sample.txt"

命令 结果
${filename%*.} this.is.a.sample (从右向左删除第一个点右边的,非贪婪模式)
${filename%%*.} this (从右向左删除最后一个点右边的,贪婪模式)
${filenam#*.} is.a.sample.txt (从左向右删除第一个点左边的,非贪婪模式)
${filenam##*.} txt (从左向右删除最后一个点左边的,贪婪模式)
This post is licensed under CC BY 4.0 by the author.