//View Tip #846
Similar Tips
» Find and remove core files
» Remove empty directories
» Delete old files
» Find files by modified time
» Finding log files X number of days old and deleteing them.


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
find . -name *whatyouwant* -exec perl -pi.bak -e 's/toto/foo/g' {} \;

Replace toto by foo in all file found by find.
It make a backup $file.bak

View Comments »


Add your comment

Comments are currently disabled
find . -name *whatyouwant* -exec `tee "{}"".bak" | sed -i 's/toto/foo/g'` \;

pure shell solution
Posted 2009-07-19 01:45:28
How about we eliminate a pipe and just do:

find . -name *whatyouwant* -exec sed -i.bak 's/toto/foo/g' {} \;
Posted 2010-06-11 21:41:31

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit