Priyanka.Patil Priyanka.Patil - 4 months ago 20
Linux Question

Sed expression with escape sequence

I need to replace the string

'../lib' to '/usr/share/server/bootstrap/lib'
in a file bootstrap.sh

I used the following sed expression

sed -i -e 's//././/lib///user//share//server//bootstrap//lib/g' bootstrap.sh


It fails with the log

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


Unable to identity the mistake in the expression.Kindly help.

Answer

You need to escape every . and /

sed -i -e "s/\.\.\/lib/\/usr\/share\/server\/bootstrap\/lib/" bootstrap.sh