Doing this with the typical delimiter '/' can look pretty ugly due to escape characters:
$ echo /my/old/path | sed 's/\/my\/old\/path/\/this\/new\/path/g'
/this/new/path
However this looks much cleaner by changing delimiter, the char after 's':
$ echo /my/old/path | sed 's|/my/old/path|/this/new/path|g'
/this/new/path
Thanks!
ReplyDeletecan you tell why did i got the below?
sed -i 's|/$EASY_RSA/keys/|/etc/openvpn/keys/g' /etc/openvpn/easy-rsa/2.0/vars
sed: -e expression #1, char 38: unterminated `s' command
You are mising the closing |:
ReplyDeletesed -i 's|/$EASY_RSA/keys/|/etc/openvpn/keys/|g' /etc/openvpn/easy-rsa/2.0/vars