${var#str} 从左向右匹配,非贪婪匹配,截取并保留右边的内容
txt='123456abc123456'
echo ${txt#*34}
# 56abc123456
${var##str} 从左向右匹配,贪婪匹配,截取并保留右边的内容
txt='123456abc123456'
echo ${txt##*34}
# 56
${var%str} 从右向左匹配,非贪婪匹配,截取并保留左边的内容
txt='123456abc123456'
echo ${txt%34*}
# 123456abc12
${var%%str} 从右向左匹配,贪婪匹配,截取并保留左边的内容
txt='123456abc123456'
echo ${txt%%34*}
# 12
${var:index:len} 正序从index位置开始截取并保留右边len个字符
txt='123456abc123456'
echo ${txt:5:3}
# 6ab
# index从0开始
${var:0-index:len} 倒序从index位置开始截取并保留右边len个字符
txt='123456abc123456'
echo ${txt:0-5:3}
# 234
# index从1开始