I am making a find and replace of BASH variables, like this:
sed -i "s/$i/$j/g" ./file
I want to pad the replacement with the letters “EE”, like this:
sed -i "s/$i/EE$jEE/g" ./file
Unfortunately, this confuses BASH into thinking $jEE is the variable. I have tried this:
sed -i "s/$i/EE$j\EE/g" ./file
However, the \E disappears, so only one “E” appears.
How can I replace $i with a $j that is surrounded by “EE”. E.g.:
i = hello
j = EEhelloEE
1 Answer