-3

I want to migrate a domain from a server to another. I want to find and replace all the strings with the old name with the new one using ssh. What is the right command in putty?

For example find John inside the files of a folder and rename it with Bill

jww
  • 97,681
  • 90
  • 411
  • 885
Bakar
  • 43
  • 7
  • 2
    Possible duplicate of [How do I find all files containing specific text on Linux?](https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux) – Chopi Apr 19 '18 at 07:31
  • Stack Overflow is not a code writing service. Please show your code. Since Stack Overflow hides the Close reason from you: *Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/).* – jww Apr 19 '18 at 08:58

1 Answers1

-1

for replacing single file you can use

sed -i -e 's/John/Bill/g' /tmp/file.txt

and for searching files you can use

find . -name "*.txt" -print

when you combine them with -exec, you will get the result which you are looking for.

find . -name "*.txt" -exec sed -i -e 's/John/Bill/g' {} +
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72