Reputation: 169
I have one configuration file than i need change automatic with a script..
G:\xampp\www\myweb
/srv/myweb/public_html
I try to use all options posible with
sed -i \"s/G:\\xampp\\www\\myweb/\/srv\/myweb\/public_html/g\" myfile.php
But i can not make this work, any help???
The solution must be using bash because is runing inside a huge script.. thanks for any advice
Upvotes: 0
Views: 1153
Reputation: 15461
Try to unescape the quotes surrounding the command and escape \
like this:
sed -i "s/G:\\\xampp\\\www\\\myweb/\/srv\/myweb\/public_html/g" file
Upvotes: 1
Reputation: 23667
$ echo 'foo G:\xampp\www\myweb bar' | sed 's#G:\\xampp\\www\\myweb#/srv/myweb/public_html#g'
foo /srv/myweb/public_html bar
Use single quotes and use a delimiter different than /
that doesn't appear in search/replacement terms (any character other than \
and newline characters can be used as delimiter)
\
is meta character, use \\
to represent it literally
Upvotes: 0
Reputation: 18687
This will do it:
sed 's|G:\\xampp\\www\\myweb|/srv/myweb/public_html|g' -i myfile.php
We're using |
as delimiter in sed
search command (instead of the default /
) to avoid escaping of /
, and a single quotes around everything to avoid double escaping of \
.
Upvotes: 1