From owner-freebsd-questions@FreeBSD.ORG Sun Dec 24 14:59:56 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 19EA016A403 for ; Sun, 24 Dec 2006 14:59:56 +0000 (UTC) (envelope-from antennex@hotmail.com) Received: from bay0-omc1-s26.bay0.hotmail.com (bay0-omc1-s26.bay0.hotmail.com [65.54.246.98]) by mx1.freebsd.org (Postfix) with ESMTP id 075CC13C466 for ; Sun, 24 Dec 2006 14:59:55 +0000 (UTC) (envelope-from antennex@hotmail.com) Received: from hotmail.com ([65.55.130.109]) by bay0-omc1-s26.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Sun, 24 Dec 2006 06:59:55 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 24 Dec 2006 06:59:55 -0800 Message-ID: Received: from 65.55.130.123 by by125fd.bay125.hotmail.msn.com with HTTP; Sun, 24 Dec 2006 14:59:51 GMT X-Originating-IP: [65.68.247.73] X-Originating-Email: [antennex@hotmail.com] X-Sender: antennex@hotmail.com In-Reply-To: <20061224075632.GB97940@holestein.holy.cow> From: "Jack Stone" To: freebsd-questions@freebsd.org Date: Sun, 24 Dec 2006 08:59:51 -0600 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 24 Dec 2006 14:59:55.0696 (UTC) FILETIME=[2C535B00:01C7276C] Subject: Re: Search & Replace Issue X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Dec 2006 14:59:56 -0000 >From: Parv >To: Josh Paetzel >CC: Jack Stone , freebsd-questions@freebsd.org >Subject: Re: Search & Replace Issue >Date: Sun, 24 Dec 2006 02:56:32 -0500 > >in message <200612232230.58352.josh@tcbug.org>, >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: > > > > > >
  • > > > > > > perl -p0777i -e 's/http:\/\/www.domain.com\///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=")\Qhttp://www.domain.com!!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=")\Qhttp://www.domain.com!!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, Jack _________________________________________________________________ Get live scores and news about your team: Add the Live.com Football Page www.live.com/?addtemplate=football&icid=T001MSN30A0701