Find and replace a string in all the files recursively

29.12.12
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

No comments:

Post a Comment