[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cobalt-developers] Re:  find and replace shell script
- Subject: RE: [cobalt-developers] Re:  find and replace shell script
 
- From: "Matthew Nuzum" <cobalt@xxxxxxxxxxxxx>
 
- Date: Sun Apr  7 05:51:19 2002
 
- Organization: Bearfruit.org
 
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
 
Master!  I'm not worthy...
;-)
Matt
>--__--__--
>
This might also help, done starting at the root of where the files may 
be expected to occur:
    find . -type f -exec perl -p -i.bak -e 
's!http://(.*\.?)domain.com/images!/images!g' {} \;
This is a find(1L) command, looking for normal files, and on each 
executing (-exec) the perl(1) one-liner (by way of the -e) to edit the 
file given to the exec function (via the {} ) in-place (-i),  making a 
backup (with the extension .bak), looking thru the file (via the -p), 
executing a substitution (s) for all instances on the line (g), using 
the '!' as a seperator, replacing "http://" followed by zero or more of 
any character, followed by 0 or 1 '.', followed by "domain.com/images/" 
with the string "/images/". (Single quotes were necessary above to 
prevent the shell from attempting to interpret the '!'s, although 
another character could also be used as a seperator for the values in 
the substitution.)
While YMMV, I hope that helps.
-Albert C.
_______________________________________________
cobalt-developers mailing list
cobalt-developers@xxxxxxxxxxxxxxx
http://list.cobalt.com/mailman/listinfo/cobalt-developers