3

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!

Elliot Reed
  • 739
  • 3
  • 11
  • 28
  • possible duplicate of [Sed - unknown option to \`s'](http://stackoverflow.com/questions/9366816/sed-unknown-option-to-s) – tripleee Aug 10 '14 at 08:28

1 Answers1

4

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
perreal
  • 94,503
  • 21
  • 155
  • 181
  • And just like that it's worked! You are quite right with the slashes in the date, I didn't even consider that! Thank you very much :) – Elliot Reed Jul 18 '13 at 08:52