i am trying to run the following in a script. It basically appends TXT_NEW after TXT with the define variables. Running the script wrapped in a small bash script throws an error:
sed: -e expression #1, char 1: unknown command: `''
#!/bin/bash
user="Alpine"
new_user="Volverine"
file_name=file.txt
TXT="This Text is by $user"
TXT_NEW="This is owned by $new_dev"
sed -i "'/$TXT/a ${TXT_NEW}'" $file
In order to trouble shoot i echoed the sed command using as follows:
echo sed -i "'/$TXT/a ${TXT_NEW}'" $file
And i see the variables expand correctly like this:
sed -i '/This Text is by Alpine/a This is owned by Volverine' file.txt
Appreciate if someone can have a look and provide some pointers...