In my project in .sh file I wrote this command:
var1=`sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g;s/^/"/g;s/$/"/g' ${var}`
sed -i "s/%PQR%/$var1/g" file2
Here var is the variable which stores location of the file that I want to update. I want double quotes to be added at the start and end of file. Also I want all the new lines to be replaced with \n.
example:
To err is to human.
This is life.
output:
"To err is to human.\nThis is life."
Then I want %PQR% in file2 to be replaced with var1.
But on running pipeline, the get the error on the second command as described in the title:
sed: -e expression#1 char 48: unterminated `s' command