Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-28-2001, 07:46 PM   #1
Veiga
Confirmed User
 
Join Date: Jun 2001
Location: Portugal
Posts: 157
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




------------------
______ All Boys Do What They Have To Do ______
http://www.powergirlz.com/webmasters
______________________________________________
Veiga is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2001, 08:51 PM   #2
Midnight
Confirmed User
 
Midnight's Avatar
 
Join Date: Jun 2001
Location: ONLINE
Posts: 330
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]
Midnight is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2001, 09:36 PM   #3
Crutch
Confirmed User
 
Join Date: Mar 2001
Location: Los Angeles
Posts: 224
Excellent tip Veiga! Thanks.

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://asp2php.naken.cc/
Crutch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2001, 11:53 PM   #4
kush
Confirmed User
 
Join Date: Feb 2001
Posts: 3,382
Veiga let me be the first to welcome you here to GFY!!!

Glad to see you came aboard, welcome man!

------------------
<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
kush is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.