![]() |
Easily replace strings at your sites
Hello again.
The other day I needed to replace a sponser code on all of my sites. As I put all of my sites in a domain, that task was very easily done with a single linux command with the help of perl. Lets see how. I am on directory /home/mydomain.com and wanted to change the url http://www.old.com to http://www.new.com on all of my sites wich are located in directories of /home/mydomain.com how I did this? with this code: perl -p -i -e 's/oldcode/newcode/g' `find ./` with this code do is actually go thru all of your files of all your subdirectories, and whenever it founds the string oldcode it replaces with the newcode. please not you need to escape with a \ all of these chars: \ . & and some other. the final code for this one would be this: perl -p -i -e 's/http:\/\/\/www\.old\.com/http:\/\/\/www\.new\.com/g' `find ./` if you want just to replace your files in the current dir, just replace `find ./` with * hope i saved some of you guys a lot of work http://bbs.gofuckyourself.com/board/smile.gif ------------------ ______ All Boys Do What They Have To Do ______ http://www.powergirlz.com/webmasters ______________________________________________ |
Thanks,
I am an asp/nt wiz, but just got a Unix host. I appreciate all the perl tidbits, they certainly help. I know that in all the years I have been programming, too often I hear the response "RTFM" , and it is just left at that. Thanks again. ------------------ Midnight Webmaster Midnight Ventures a little bit of nasty can be so nice [email protected] |
Excellent tip Veiga! Thanks. http://bbs.gofuckyourself.com/board/smile.gif
Midnight, most of the tech heads are over at the AWI board if you need something answered. IRC is great place to...found lots of php/linux tricks there. Come on Midnight..you know you want to..hehe.. http://bbs.gofuckyourself.com/board/smile.gif http://asp2php.naken.cc/ |
Veiga let me be the first to welcome you here to GFY!!!
Glad to see you came aboard, welcome man! http://bbs.gofuckyourself.com/board/biggrin.gif ------------------ <A HREF="http://www.dailysteam.com/webmasters.html" TARGET=_blank> My Webmaster's Page</A> General Webmaster Info, seen from my point of view ;)<A HREF="http://www.dailysteam.com/sponsors.html" TARGET=_blank> Sponsors List Page</A> Organized, honest listing of sponsors and my comments on them |
| All times are GMT -7. The time now is 02:38 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123