Wednesday, July 29, 2009

Search and Replace in Linux

I found this neat snippet as an alternative for 'sed' to search and replace a string in multiple files in Linux. Enjoy:

perl -pi -w -e 's/search/replace/g;' *.php
-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop