Find and replace using shell command

Tech Orient

How to do find and replace using shell command

Recursively replace a word in multiple files in multiple directories?

grep -lr `old-pattern` * | xargs -i@ sed -i `s/old-pattern/new-pattern/g` @

Which will find the old-pattern in each file, complete with path, then pipe through xargs and run sed does the trick.

View original post

Publicités
Par défaut