[oclug] ...and speaking of awk...
Dave O'Neill
doneill at linuxcare.com
Thu Feb 22 15:38:55 EST 2001
On Thu, 22 Feb 2001, Dave Edwards wrote:
> 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">
Well, I've long since forgotten awk and sed (time for a Francis rant?),
but you can do this with a Perl oneliner:
perl -pi.bak -e 's!<a href="http://some.url/([^"]*)">!<a href="./$1">!g' *.html
This (should... I haven't tested it to make sure) do what you want, with
the added bonus of saving all modified files as <whatever>.html.bak in
case something nasty happens.
Dave
--
Dave O'Neill, Senior Linux Consultant
Linuxcare, Inc. tel: (613) 562-9949 fax: (613) 562-9700
doneill at linuxcare.com http://www.linuxcare.com/
Linuxcare. Putting open source to work.
More information about the OCLUG
mailing list