test> var=http://www.aaa.com/123.htm test> echo ${var#*//} www.aaa.com/123.htm test> echo ${var##*/} 123.htm test> echo ${var%/*} http://www.aaa.com test> echo ${var%%/*} http: test> echo ${var:0:5} http: test> echo ${var:7} www.aaa.com/123.htm test> echo ${var:0-7:3} 123 test> echo ${var:0-7} 123.htm
# 去左边
%去右边
单一符号是最小匹配;两个符号是最大匹配