${var#key}
从左往右删除最短的key
${var##key}
从左往右删除最长的key
${var%key}
从右往左删除最短的key
${var%%key}
从右往左删除最长的key
${var/key/new}
替换第一个匹配字符串
${var//key/new}
替换全部匹配字符串
zmc@SUSE11:~> path=$PATH
zmc@SUSE11:~> echo $path
/usr/java/jdk1.6.0_20/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/tt/TimesTen/tt7/bin:./
zmc@SUSE11:~> echo ${path#*bin:}
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/tt/TimesTen/tt7/bin:./
zmc@SUSE11:~> echo ${path##*sbin:}
/tt/TimesTen/tt7/bin:./
zmc@SUSE11:~> echo ${path/tt/gg}
/usr/java/jdk1.6.0_20/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/gg/TimesTen/tt7/bin:./
zmc@SUSE11:~> echo ${path//tt/gg}
/usr/java/jdk1.6.0_20/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/gg/TimesTen/gg7/bin:./