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 ~]# 
posted @ 2019-02-20 09:22  tsing0520  阅读(239)  评论(0编辑  收藏  举报