bulk search and replace on unix using perl

here’s a example of how you might do a bulk search and replace on unix – here i’m replacing all occurences of old style br tags with xhtml br tags:

perl -pi -e ‘s@<br>@<br />@g’ * (this will replace all instances in all files in the current directory)

find . -type f | xargs perl -pi -e ‘s@<br>@<br />@g’ (this version will search subdirectories too)

EDIT: remember that bulk search and replace can be dangerous, and also bear in mind that if you use subversion like we do, the method described above will affect the .svn files too. This appears to be a BAD THING