我有以下字符串
str="toto1 toto2 toto3 toto4 toto2 toto5"
Run Code Online (Sandbox Code Playgroud)
在toto2字符串中出现了两次.如何toto2从字符串中删除所有出现的内容?
我试过这个:
echo ${str/toto2/}
Run Code Online (Sandbox Code Playgroud)
但这只会删除第一次出现的toto2.
toto1 toto3 toto4 toto2 toto5 # output
Run Code Online (Sandbox Code Playgroud)
如何toto2从字符串中删除所有出现的内容?