Bash pattern match
1. 起因:Shell 获取文件名和后缀名 [_posts] ==>> file="A-Tale-Of-Two-Cities.pdf" [_posts] ==>> echo "${file%.*}" A-Tale-Of-Two-Cities [_posts] ==>> echo "${file##*.}" pdf 2. 基于 Pattern Matching 的子串替换 ${str/$old/$new} 替换第一个。 ${str//$old/$new} 替换所有。 注意:不能使用正则表达式,只能使用 ?* 的Shell扩展。只能用shell通配符如 *? [list] [!list] [a-z]。 ...