printf '%s' 'abc' | sed 's/./\\&/g' #1, \a\b\c
printf '%s' "`printf '%s' 'abc' | sed 's/./\\&/g'`" #2, &&&
The expression inside the second backticks returns \a\b\c
, and we have printf '%s' "\a\b\c"
, so it should print \a\b\c
.
My question is: why does the second script print &&&
?
note:
I can get the second script work (prints \a\b\c
) by prepending each backslash with another backslash, but I don't know why it's needed.
One related question: why does this single quoted string get interpreted when it's inside of a command substitution