[oclug] ...and speaking of awk...

Adrian Chung adrian at enfusion-group.com
Thu Feb 22 15:55:11 EST 2001


On Thu, Feb 22, 2001 at 02:45:45PM -0500, Dave Edwards wrote:
> Hey Gang,
> 
> I need to alter a directory worth of downloaded html files so that the
> links reference only ./   "this directory."  But I can't wrap my head
> around the re necessary to do this.  In very loose pseudo, it would be:
> 
> when, in any field, <a href="http://some.url/file.html"> is found, replace
> that with <a href="./same-filename.html">

Try this:

perl -pi -e 's/http:\/\/some.url/\./g'

in the directory your files are in.

It'll go through each file in the directory, and replace the above
pattern.

For extra cautiousness, you can do a:

perl -pi.bak -e 's/http:\/\/some.url/\./g'

And it'll copy any of the files it modifies, in original form to
<filename>.bak.

Good luck!

--
Adrian Chung - adrian at enfusion dash group dot com




More information about the OCLUG mailing list