From owner-freebsd-questions@FreeBSD.ORG Tue Dec 30 21:16:46 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 199BD10656CF for ; Tue, 30 Dec 2008 21:16:46 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr12.xs4all.nl (smtp-vbr12.xs4all.nl [194.109.24.32]) by mx1.freebsd.org (Postfix) with ESMTP id 894C48FC1B for ; Tue, 30 Dec 2008 21:16:45 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr12.xs4all.nl (8.13.8/8.13.8) with ESMTP id mBULGgtZ056429; Tue, 30 Dec 2008 22:16:43 +0100 (CET) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id 7259CB84E; Tue, 30 Dec 2008 22:16:42 +0100 (CET) Date: Tue, 30 Dec 2008 22:16:42 +0100 From: Roland Smith To: Gary Kline Message-ID: <20081230211642.GA67769@slackbox.xs4all.nl> References: <20081230193111.GA32641@thought.org> <20081230201623.GB65659@slackbox.xs4all.nl> <20081230205131.GA34211@thought.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: <20081230205131.GA34211@thought.org> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: FreeBSD Mailing List Subject: Re: well, blew it... sed or perl q again. 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: Tue, 30 Dec 2008 21:16:46 -0000 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 30, 2008 at 12:51:31PM -0800, Gary Kline wrote: > On Tue, Dec 30, 2008 at 09:16:23PM +0100, Roland Smith wrote: > > On Tue, Dec 30, 2008 at 11:31:14AM -0800, Gary Kline wrote: > > > The problem is that there are many, _many_ embedded=20 > > > " Site in my hundreds, or > > > thousands, or files. I only want to delete the > > > "http://" lines, _not_ the other Href links. > > >=20 > > > Which would be best to use, given that a backup is critical? > > > sed or perl? > >=20 > > IMHO, perl with the -i option to do in-place editing with backups. You > > could also use the -p option to loop over files. See perlrun(1). > >=20 > > Roland >=20 >=20 > All right, then is this the right syntax. In other words, do > I need the double quotes to match the "http:" string? >=20 > perl -pi.bak -e 'print unless "/m/http:/" || eof; close ARGV if eof' * You don't need the quotes (if the command doesn't contain anything that your shell would eat/misuse/replace). See perlop(1). =20 This will disregard the entire line with a URI in it. Is this really what you want? Copy some of the files you want to scrub to a separate directory, and run tests to see if your script works: mkdir mytest; cp foo mytest/; cd mytest; perl -pi.bak ../scrub.pl foo diff -u foo foo.bak=20 Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --yrj/dFKFPuw6o+aM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAklaj7oACgkQEnfvsMMhpyUZbACePuqcE/gh+OafRN4PYnoF11H1 o+0AoJY+O/fkUAUIy06oxpURouVuZSux =G1Sm -----END PGP SIGNATURE----- --yrj/dFKFPuw6o+aM--