Bash string replace

Content

Bash replace first substring match or all substring matches.

$ cat test.sh find="b" replace="B" in="abcabc"   echo "find: ${find}" echo "replace: ${replace}" echo "in: ${in}"   echo "${in/$find/$replace}" echo "${in//$find/$replace}"   $ bash test.sh find: b replace: B in: abcabc aBcabc aBcaBc