[PLUG] replacing multipule instances of text

alex alexlinux at qwest.net
Tue Sep 30 08:39:02 UTC 2003


WOW! Thanks everyone. Printing this all out as I type. I'm definitely
not a Perlmonger but I'll back up and try anything once. To answer a few
of the questions, yes they are all static pages although I did use a
small program to build them and I did hack the CSS page to get the right
color for the background. The pages are nested and here is the link for
anyone that interested to see what I've done.

www.borderline.dns2go.com/RCTCphotos.html

Thanks again.

Alex McCreay


On Tue, 2003-09-30 at 08:01, Paul Heinlein wrote:
> On Tue, 30 Sep 2003, alex wrote:
> 
> > I need to replace all the homepage links in the HTML with the
> > updated address.
> >
> > ex. replace www.foobar.com/RCTC/ with www.RCTC.com/
> >
> > My question is..... is there an easy way to do this other than the
> > obvious highlight and pasting of text?
> 
> Here's what I'd do, assuming that your example is correct. Let's say
> that the documents are all in /var/www/rctc/public_html.
> 
>   #!/bin/sh
>   #
>   # out with old, in with the...
>   oldurl="www.foobar.com/RCTC/"
>   newurl="www.RCTC.com/"
>   # make a backup copy of the document root
>   mkdir /tmp/rctc
>   cd /var/www/rctc
>   tar cf - ./public_html | ( cd /tmp/rctc && tar xf -)
>   # using the backup as a base, overwrite the production copies
>   cd /tmp/rctc
>   for f in $(grep -lr "$oldurl" public_html); do
>     sed -e "s!$oldurl!$newurl!g" < $f > /var/www/rctc/$f
>   done
>   # make sure any remaining foobar references are valid
>   grep -r 'www\.foobar\.com' /var/www/rctc/public_html/*
> 
> If something goes horribly wrong, you can always restore the temp copy
> of the tree to the production environment. Otherwise, delete the temp
> tree and head off to enjoy a cold beverage of your choice. :-)
> 
> --Paul Heinlein <heinlein at madboa.com>
> 
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
-- 
alex <alexlinux at qwest.net>





More information about the PLUG mailing list