This site is moved to other domain!

You should be automatically redirected in 9 seconds. If not, visit
http://www.detector-pro.com
and update your bookmarks.

Wednesday, February 4, 2009



Stumble Upon Toolbar
written by: Ukion in
[] [] [] []

Linux tip: How to replace text in multiple files


Don't want to miss a single bit? Subscribe to our RSS Feed!


If you have text you want to replace in multiple locations, there are several ways to do this. To replace the text Windows with Linux in all files in current directory called test[something] you can run this:

perl -i -pe 's/Windows/Linux/;' test*
To replace the text Windows with Linux in all text files in current directory and down you can run this:
find . -name '*.txt' -print | xargs perl -pi -e's/Windows/Linux/ig' *.txt
Or if you prefer this will also work, but only on regular files:
find -type f -name '*.txt' -print0 | xargs --null perl -pi -e 's/Windows/Linux/'
Good luck! It saves a lot of time and it is excellent tip for every advanced Linux user!




Subscribe to DetectorProDid you enjoy this post? Why not leave a comment below and continue the conversation, or Subscribe to Feed and get articles like this delivered automatically to your Email or feed reader.



Related articles by tags



0 comments: