To: Josh Paetzel <[EMAIL PROTECTED]>
Subject: Re: Search & Replace Issue
Date: Sun, 24 Dec 2006 02:56:32 -0500

in message <[EMAIL PROTECTED]>,
wrote Josh Paetzel thusly...
> On Saturday 23 December 2006 21:29, Jack Stone wrote:
> > Appreciate a tip on how to search & replace  hundreds of *.htm
> > files:
> > >From this:
> >
> > <li><a href="
> > To this:
> > <li><a href="tales/wouf.html
> >
> perl -p0777i -e 's/http:\/\/\///g' *.htm

Is -0777 really necessary (causes whole file to be stored in
memory)?  But that is not really the point of this reply.

Above is a fine opportunity to use alternative delimiters (and to
restrict the matching (only to link URLs)) ...

  perl -pi -e 's!(?<=href=")\Q!!g' *.html

... in case of "hundreds of *.htm", use xargs(1) pipeline ...

  find  dir-of-HTML-files  -type f -name '*.html' -print0 \
  | xargs -0 perl -pi -e 's!(?<=href=")\Q!!g'

Feel free to change Perl version with sed (the version of sed with
-i option[0]) one ...

  find ... \
  | ... sed -i -e 's,\(href="\)http://www\.domain\.com,\1,g'

  [0] That makes this reply on point.

  - Parv

Parv and all:
Many thanks for these various tips and your time to make them!

I usually use sed(1) myself, but for the life of me, I could not find a way to properly apply delimiters or syntax to get it to work. I was close, but no cigar! Too many slashes and commas I guess.

Such a "tool" will indeed be a giant timesaver!

Merry Xmas!

All the best,

Get live scores and news about your team: Add the Football Page

_______________________________________________ mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to