Replace windows path with linux path using sed in a file

I have one configuration file than i need change automatic with a script..

  • Original path: G:\xampp\www\myweb
  • New path: /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


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 \.


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