Double quotes and variables in Sed - Unknown expression?

bash, sed, variables

Solution

I think you have slashes in `THEDATE`, which are being confused as regex delimiters by sed. Try changing the substitution delimiter, for example with `!`:

sed -i 's!$!,"123456","789101112","0001",'"$THEDATE"',"DDX"!' /tmp/tmp02.csv

Problem

Right, so in a Bash script I have the following line: ``` sed -i 's/$/,"123456","789101112","0001",'"$THEDATE"',"DDX"/' /tmp/tmp02.csv ``` However, whenever I run it I always get the error ``` sed: -e expression #1, char 42: unknown option to `s' ``` I think it's the variable bit, but however I do it it won't seem to escape the double quotes.. Any help greatly appreciated!

Original source

Related problems