Bulk replace with perl
There is a very cool set of options in perl that allows you to replace a string in a file.
perl -pi -e ‘s/str1/str2/g’ file
and when you need it for a full directory, it becomes even more powerful
for i in *; do perl -pi -e ‘s/str1/str2/g’ $i; done
And the ultimate option, perl -pi.bak [...] which backup the old version of the file with the extension “.bak”.
I knew this option since a while, but I never remember it… so when I need it, I always have to look right and left to find it again… Now it’s blogged!