- Debian Admin - http://www.debianadmin.com -

Howto Replace multiple file text string in Linux

Posted By Admin On 13th August 2007 @ 13:42 In General | 3 Comments

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

If you have a folder with a lot of files in a directory and with a specific string that you want to change you can do it in seconds using grep and perl command line

grep -R –files-with-matches ‘OLDSTRING’ . | sort | uniq | xargs perl -pi~ -e ’s/OLDSTRING/NEWSTRING/’

Where OLDSTRING is the string you want to find and replace with NEWSTRING.

Tags: ,

You may also be interested in...


Article printed from Debian Admin: http://www.debianadmin.com

URL to article: http://www.debianadmin.com/howto-replace-multiple-file-text-string-in-linux.html

Click here to print.