4

I have a little problem.

I try to replace a string(well a line) by a $variable in a file.

So I use the command :

sed -i -e "s/conf .*/conf = $PATH_CONF/g" generals.conf

If PATH_CONF does not contains specials characters like "/", it's working.

But PATH_CONF contains a path(/home/etc.) so it has several "/", then I got an error :

 bad flag in substitute command: 'h' 

So how must I do to have specials characters in my $variable ?

thanks.

Pompom Pidou
  • 135
  • 1
  • 3
  • 7

1 Answers1

8

Try:

sed -i -e "s@conf .*@conf = $PATH_CONF@g" generals.conf

You need the identical chars as separators (here @), not three /s necessarily.

Mithrandir
  • 24,869
  • 6
  • 50
  • 66