Saturday, December 29, 2012

Find and replace a string in all the files recursively

How to do a Find and replace a string in all the files recursively in unix:
Its very simple:
find . -type f|xargs perl -pi -e 's/source/target/g'
or
find . -type f -exec perl -pi -e 's/source/target/g' {} \;
Another way
find . -type f -exec sed -i 's/source/target/g' {} \;

No comments:

Post a Comment