How would I use a variable -containing spaces- as values in sed? - I'm using sh
(not bash
) as terminal.
What I'm trying to do (insert a b c
in the first line of the file):
TMP='a b c'
sed -e '1i'${TMP} tmp.txt
However this errors with the message
dynamic-config-manager-nginx.sh: -: not found
And in the files I only see the first a
inserted. - It seems that sed
is exiting too early. "forcing" quotes around the string like below also doesn't work, with "
command not found
sed -e '"1e'${TMP}'"' tmp.txt
So how do I make this work?