变量设置方式   示例
${变量#关键字}若变量内容从头开始的数据符合关键字,则将符合的最短数据删除

A=abc123abc1234aa123bb123cc

echo ${A#*abc}

结果:abc123abc1234aa123bb123cc
${变量##关键字}若变量内容从头开始的数据符合关键字,则将符合的最长数据删除

A=abc123abc1234aa123bb123cc

echo ${A##*abc}

结果:abc123abc1234aa123bb123cc
${变量%关键字}若变量内容从尾向前的数据符合关键字,则将符合的最短数据删除

A=abc123abc1234aa123bb123cc

echo ${A%123*}

结果:abc123abc1234aa123bb123cc
${变量%%关键字}若变量内容从尾向前的数据符合关键字,则将符合的最长数据删除

A=abc123abc1234aa123bb123cc

echo ${A%%123*}

结果:abc123abc1234aa123bb123cc
${变量/旧字符串/新字符串}若变量内容符合旧字符串,则第一个旧字符串会被新字符串替换

A=abc123abc1234aa123bb123cc

echo ${A/abc/ABC}

结果:ABC123abc1234aa123bb123cc
${变量//旧字符串/新字符串}若变量内容符合旧字符串,则全部的旧字符串会被新字符串替换

A=abc123abc1234aa123bb123cc

echo ${A//abc/ABC}

结果:ABC123ABC1234aa123bb123cc