A=abc123abc1234aa123bb123cc
echo ${A#*abc}
结果:abc123abc1234aa123bb123ccA=abc123abc1234aa123bb123cc
echo ${A##*abc}
结果:abc123abc1234aa123bb123ccA=abc123abc1234aa123bb123cc
echo ${A%123*}
结果:abc123abc1234aa123bb123ccA=abc123abc1234aa123bb123cc
echo ${A%%123*}
结果:abc123abc1234aa123bb123ccA=abc123abc1234aa123bb123cc
echo ${A/abc/ABC}
结果:ABC123abc1234aa123bb123ccA=abc123abc1234aa123bb123cc
echo ${A//abc/ABC}
结果:ABC123ABC1234aa123bb123cc原文地址:http://blog.51cto.com/lythjq/2073386