From owner-freebsd-questions@FreeBSD.ORG Sun Dec 24 08:11:27 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 E1F9916A58C for ; Sun, 24 Dec 2006 08:11:27 +0000 (UTC) (envelope-from parv@pair.com) Received: from mta10.adelphia.net (mta10.adelphia.net [68.168.78.202]) by mx1.freebsd.org (Postfix) with ESMTP id 9AA8F13C48A for ; Sun, 24 Dec 2006 08:11:27 +0000 (UTC) (envelope-from parv@pair.com) Received: from default.chvlva.adelphia.net ([69.160.66.115]) by mta10.adelphia.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20061224075613.YKGR11646.mta10.adelphia.net@default.chvlva.adelphia.net>; Sun, 24 Dec 2006 02:56:13 -0500 Received: by default.chvlva.adelphia.net (Postfix, from userid 1000) id 7D280B5AD; Sun, 24 Dec 2006 02:56:32 -0500 (EST) Date: Sun, 24 Dec 2006 02:56:32 -0500 From: Parv To: Josh Paetzel Message-ID: <20061224075632.GB97940@holestein.holy.cow> Mail-Followup-To: Josh Paetzel , freebsd-questions@freebsd.org, Jack Stone References: <200612232230.58352.josh@tcbug.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200612232230.58352.josh@tcbug.org> Cc: Jack Stone , freebsd-questions@freebsd.org 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 08:11:28 -0000 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 --