Quick Search and Replace inside a file with perl

Almost every day I need to search and replace inside a file.   This is done very easily with vi but a little harder on multiple files.  Take this example I want to search all the files in the current directory ending in .conf and find the word jgriffiths.org and replace it with jgriffiths.com.    Perl to the rescue with this simple one line fix

perl -pi -e 's/jgriffiths.org/jgriffiths.com/g' *.conf

Yes it’s that simple.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.