[GLLUG] Change text in multiple files

Ben Pfaff blp at cs.stanford.edu
Tue Jul 27 12:13:20 EDT 2004


"Seth Bembeneck" <sbdataspiller at sbcglobal.net> writes:

> Specifically, I need to change all references to “index.php” in my php scripts to “home.php”

Something roughly like this:
        find . -name \*.php -print0 | xargs -0 perl -pe 's/index\.php/home.php/g;' -i.bak --
or if you don't have a huge number of files with weird names:
        perl -pe 's/index\.php/home.php/g;' -i.bak -- `find . -name \*.php`
Then after you make sure it's okay, delete the .bak files.
-- 
"Writing is easy.
 All you do is sit in front of a typewriter and open a vein."
--Walter Smith



More information about the linux-user mailing list