ZhangZhihui's Blog  
scnzzh@zubt1:~/zzh$ str='I love python and python.'
scnzzh@zubt1:~/zzh$ echo ${str/'python'/'shell'}
I love shell and python.
scnzzh@zubt1:~/zzh$ echo ${str/python/shell}
I love shell and python.
scnzzh@zubt1:~/zzh$ echo ${str//python/shell}
I love shell and shell.

To replace all occurrences, use ${parameter//pattern/string}.

 

posted on 2020-12-23 11:23  ZhangZhihuiAAA  阅读(79)  评论(0编辑  收藏  举报