How to substitute expression globally with bash bracket substitution syntax?

Solution 1:

You can try this syntax which gives output:

$ A=aa 
$ echo ${A//a/b}
bb

${A//a/b} replaces all the matches of a with b. Whereas, ${A/a/b} will replace only 1st match of a.

More details about Bash Strings Manipulation can be found here.