1.
$ var="This is a line of text"
$ echo ${var/line/REPLACED}
This is a REPLACED of text"
2.通过指定起始位置和长度来打印子串:
${variable_name:start_position:length}
$ string=abcdefghijklmnopqrstuvwxyz
$ echo ${string:4}
efghijklmnopqrstuvwxyz
$ echo ${string:4:8}
efghijkl
echo ${string:(-1)}
z
$ echo ${string:(-2):2}
yz