5

I have file .config with line :
projdir name_of_the_projdir
I need to with replace name_of_the_projdir with my own variable. I try to do it with

sed -i 's/^projdir .*$/projdir '$projdir'/' .le/.config

but i get error

sed: -e expression #1, char 25: unknown option to `s'

anyone know what to do ?... i try to replace first ' and last with " and first and alst / with @ . But still not work

Gilles Quenot
  • 154,891
  • 35
  • 213
  • 206

1 Answers1

5

You get that error because the / delimiters you use with the substitute command are clashing with the directory separators. You can change them to something else:

sed -i 's!^projdir .*$!projdir '$projdir'!' .le/.config
perreal
  • 90,214
  • 20
  • 145
  • 172
  • Thank you! I wasn't considering the slashes in my variables (they're URLs in my case) and it was driving me nuts that no amount of escaping things everywhere else was helping anything. – Max Starkenburg Feb 15 '16 at 22:22