From owner-freebsd-questions@FreeBSD.ORG Mon Dec 22 08:53:51 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 059F51065673 for ; Mon, 22 Dec 2008 08:53:51 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 7D1E48FC1A for ; Mon, 22 Dec 2008 08:53:50 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id mBM8rh4e036670; Mon, 22 Dec 2008 08:53:45 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.7.2 smtp.infracaninophile.co.uk mBM8rh4e036670 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1229936025; bh=cx1Xu/cw55a9f3 q4Hp5TuwE6UVfoGvZBerIJni+55IA=; h=Message-ID:Date:From:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Cc:Content-Type: Date:From:In-Reply-To:Message-ID:Mime-Version:References:To; z=Mes sage-ID:=20<494F5590.3090400@infracaninophile.co.uk>|Date:=20Mon,=2 022=20Dec=202008=2008:53:36=20+0000|From:=20Matthew=20Seaman=20|Organization:=20Infracaninophile|User -Agent:=20Thunderbird=202.0.0.18=20(X11/20081125)|MIME-Version:=201 .0|To:=20Gary=20Kline=20|CC:=20freebsd-questions @freebsd.org|Subject:=20Re:=20Sed=20question|References:=20<2008122 1053407.GA87868@thought.org>=20<877i5unkx4.fsf@kobe.laptop>=09<1229 854084.6392.52.camel@ethos>=09<20081221140658.GA24691@marge.bs.l>=2 0<20081221222744.GA28185@thought.org>|In-Reply-To:=20<2008122122274 4.GA28185@thought.org>|X-Enigmail-Version:=200.95.6|Content-Type:=2 0multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A=20protocol=3D"a pplication/pgp-signature"=3B=0D=0A=20boundary=3D"------------enig9A EFF922DBF360348E8E97ED"; b=nQE+vb53fS5FadY+VikH2PdECKYTquh4+ewfKH7G +koiUIWVEYJk9B1HSLib8jaTdgsc9M/BKwvCLOdIuwr0MFXkfK4fm23P1hDi4CHr8Ja u51y2Q1iuxKbO/CcecHGojfPtBoBSazbQRcnNVpLBW+ntQ/mKnZAp9QwRcB4NRnU= Message-ID: <494F5590.3090400@infracaninophile.co.uk> Date: Mon, 22 Dec 2008 08:53:36 +0000 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Gary Kline References: <20081221053407.GA87868@thought.org> <877i5unkx4.fsf@kobe.laptop> <1229854084.6392.52.camel@ethos> <20081221140658.GA24691@marge.bs.l> <20081221222744.GA28185@thought.org> In-Reply-To: <20081221222744.GA28185@thought.org> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig9AEFF922DBF360348E8E97ED" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (smtp.infracaninophile.co.uk [IPv6:::1]); Mon, 22 Dec 2008 08:53:45 +0000 (GMT) X-Virus-Scanned: ClamAV 0.94.2/8790/Mon Dec 22 04:26:20 2008 on happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: freebsd-questions@freebsd.org Subject: Re: Sed question 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: Mon, 22 Dec 2008 08:53:51 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9AEFF922DBF360348E8E97ED Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Gary Kline wrote: > anyway, this is one for giiorgos, or another perl wiz. i've > been using the perl subsitution cmd one-liner for years with > unfailing success. is there a way of deleting lines with perl > using the same idea as: >=20 > perl -pi.bak -e 's/OLDSTRING/NEWSTRING/g' file1 file2 fileN To delete lines matching a R.E. (grep -v effectively): perl -ni.bak -e 'm/SOMETHING/ || print;' file1 file2 fileN To delete lines by number from many files -- eg. exclude lines 3 to 7: perl -ni.bak -e 'print unless ( 3 .. 7 ); close ARGV if eof;' \ file1 file2 fileN The malarkey with 'close ARGV' is necessary because otherwise perl won't reset the input line number counter ($.) for each new file. The range expression ( N .. M ) can take matching terms rather than line numbers, so you can also do things like: perl -ni.bak -e 'print unless ( m/FIRST/ .. m/SECOND/ )' \ file1 file2 fileN Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig9AEFF922DBF360348E8E97ED Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAklPVZcACgkQ8Mjk52CukIww7gCfb3eIYOJJPqIOpQlQw+sZRTsj o98AnAtxEP7HPpdpWiyXC1OiBw+8bPTh =GgrQ -----END PGP SIGNATURE----- --------------enig9AEFF922DBF360348E8E97ED--