//View Tip #846
Similar Tips
» Finding log files X number of days old and deleteing them.
» Count files by type
» dos2unix all files in a directory
» Find last modified files on a filesystem
» Remove DS_Store files from shared folders

 

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 »




Comments 

Add your comment

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

pure shell solution
Posted 2009-07-19 01:45:28
dzr
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