Find and replace a string in all the files recursively

Saturday, December 29, 2012 , , , 0 Comments

Below are some useful commands to  find and replace a string in all the files recursively in unix:

find . -type f|xargs perl -pi -e 's/source/target/g'

or
find . -type f -exec perl -pi -e 's/source/target/g' {} \;
or
find . -type f -exec sed -i 's/source/target/g' {} \;

All the three are logically similar

0 comments: