I wanted to print a variable(var="phani") to the end of a text file (2.txt) using sed.
This is my work so far:
$ var="phani";echo sed -e "$a$var" -i 2.txt
But the error i am getting is :
sed: -e expression #1, char 2: extra characters after command
Any suggestions please?
because you’re using dbl-quotes (to allow for var expansion), you have to escape the first $ so the shell doesn’t try to evaluate ‘$a’, this works for me ..
I hope this helps.