Priyanka.Patil Priyanka.Patil - 4 years ago 158
Linux Question

Sed expression with escape sequence

I need to replace the string

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

I used the following sed expression

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

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 Source

You need to escape every . and /

sed -i -e "s/\.\.\/lib/\/usr\/share\/server\/bootstrap\/lib/"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download