linux-替换字符串

grammar

使用replacement代替第一个匹配的substring

${string/substring/replacement}

使用replacement代替所有匹配的substring

${string//substring/replacement}

code

[root@localhost ~]# string=abc12342341
[root@localhost ~]# echo ${string/23/bb}
abc1bb42341
[root@localhost ~]# echo ${string}
abc12342341
[root@localhost ~]# echo ${string//23/bb}
abc1bb4bb41
[root@localhost ~]# 
原文地址:https://www.cnblogs.com/tsing0520/p/10404618.html