I am running Ubuntu 14.04 and Magento website in my Local System.

Now I have a module directory in which I want to replace every occurrence of "Magento\Module" with "MyCompany\Module" in all files inside this current folder and it's sub-directories recursively ofcourse, but I guess it's not working due to "\" are there in my search and replace string.

I have already tried:

find ./ -type f -readable -writable -exec sed -i "s/Magento\\Module/MyCompany\\Module/g" {} \;

But it doesn't work at all.

Please help anyone, it's urgent.


The shell is likely consuming one of the escapes:

$ echo sed "s/Magento\\Module/MyCompany\\Module/g"
sed s/Magento\Module/MyCompany\Module/g

So either add an additional escape or single-quote the entire expression:

$ echo sed "s/Magento\\\Module/MyCompany\\\Module/g"
sed s/Magento\\Module/MyCompany\\Module/g

$ echo sed 's/Magento\\Module/MyCompany\\Module/g'
sed s/Magento\\Module/MyCompany\\Module/g

Testing it:

$ echo 'every occurrence of "Magento\Module"' | sed 's/Magento\\Module/MyCompany\\Module/g'
every occurrence of "MyCompany\Module"
| improve this answer | |
  • @steeldriver Thanks your anwser is working perfectly, can you let me know how to replace directory names as well in this command itself along with filenames ? – Vicky Dev Dec 7 '15 at 9:36
  • @VickyDev can you edit your question to include examples? – steeldriver Dec 7 '15 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.