Posts Tagged ‘perl’

Find and replace text in all html files using PERL

Monday, September 28th, 2009

To find and replace “findme” with “replacewithme” in all HTML files in a directory /var/www/html use

find /var/www/html -name '*.html' -print0 |xargs -0 perl -p -i -e 's/findme/replacewithme/g'

To find and replace “findme” with “replacewithme” in all HTML files in a directory /var/www/html and to backup the original files as let’s say filename.unixtimestamp use

find /var/www/html -name '*.html' -print0 |xargs -0 perl -p -i.`date +%s` -e 's/findme/replacewithme/g'