文本切片与参数操作


[root@test  temp]# var="This is a line of text"
[root@test  temp]# echo ${var/line/REPLACED}
This is a REPLACED of text


[root@test  temp]# string=abcdefghijklmnopqrstuvwxyz
[root@test  temp]# echo ${string:4}
efghijklmnopqrstuvwxyz


[root@test  temp]# echo ${string:4:8}
efghijkl


[root@test  temp]# echo ${string:(-1)}
z


[root@test  temp]# echo ${string:(-2)}
yz


[root@test  temp]#

你可能感兴趣的:(String)