Re: Find and Replace

From: Date: Mon, 30 Jul 2001 19:23:11 +0000
Subject: Re: Find and Replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60265@lists.php.net to get a copy of this message
Try this: ---cut--- ################### # Finds all *.inc from current directory and rename then to *.inc.php # then edit that file and replace all references to it as well # I haven't tested this, but it should work, but don't be a dumbass and not make a backup copy # of your files before running it :-) # Note: You may need to escape the $ symbols (\$) in the perl command (I don't remember) #################### #!/bin/sh for file in find . -name '*.inc' | awk -F. {print $1} do echo "Processing $file.inc" mv $file.inc $file.inc.php perl -i -pe 's/$file.inc/$file.inc.php/g' $file.inc.php done ---cut--- ----- Original Message ----- From: "Shrout, Ryan" <Rshrout@krauss-maffeicorp.com> To: <php-general@lists.php.net> Sent: Monday, July 30, 2001 3:06 PM Subject: [PHP] Find and Replace > This isn't exactly PHP I need help with, but it relates to what I learned > about security. Up until now, I have been using *.inc extensions for my > include files. Well, I didn't realize until recently that anyone can view > these files. So, I want to rename them to *.inc.php. BUT, in almost all of > my PHP pages, there are links to : include ('mydir/myfile.inc'); > > Can someone tell me how to do a recursive find and replace to look for > /myfile.inc and replace it with myfile.inc.php? I am running Red Hat 7.1 > > Thanks! > > Ryan > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#60265) next »