Currently I use:
sed -i -e "5a\\
${text}" $filename
to append something to a certain line, where the variable text contains a string such as "\epsilon".
When using
echo -E $text
the string is displayed just fine, but when I expand it in the string
I pass to sed
, all escape characters get expanded and the result is
not what I would want.
How can I get sed to use the raw contents of that string without escaping anything?
$
as well. How many other special symbols that require escaping are possible for a bash string? – pmr Aug 10 '12 at 12:04a='AA'
andb='this is $a'
, thenecho $b
will just printthis is $a
. Once you makeecho
output the correct string, you only need to worry aboutsed
, andsed
only interprets backslashes, which is taken care of with the innersed
. That's all. – angus Aug 10 '12 at 13:03