I am generating sed expression in Bash script, and I am having a following problem.
I want to add a space in front of each appearance of abc.
This commands works as expected
echo abc | sed -e "s/abc/ def/"
output is " def" without quotes
whereas this commands
Q='-e "s/abc/ def/"' echo abc | sed $Q
outputs sed: -e expression #1, char 1: unknown command: `"'
Outside of bash script, everything works.
I tried all possible ways of quotes, escaping characters, but couldn't figure it out. Can someone help me?