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.

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

wow nice, didn't knew of this.
thanks a lot, didn't know either

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.