Reputation: 21
How to find and replace a file path like a/b/c/d
into x/y/z
using sed command?
I tried sed -i -e 's/a/\b/\c/\d/x/\y/\z' file.txt
but it did not work.
Upvotes: 0
Views: 168
Reputation: 142080
Just use another separator for s
command. You can use any character. Just /
is the most popular one. I like @
or #
. Then you have to escape that character.
sed 's@a/b/c/d@x/y/z@'
but it did not work
To escape /
use \/
not /\
. The \
needs to be in front of /
. You could:
sed 's/a\/b\/c\/d/x\/y\/z/'
Upvotes: 1