From owner-freebsd-questions@FreeBSD.ORG Sun Dec 21 22:27:56 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 3FC001065670 for ; Sun, 21 Dec 2008 22:27:56 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id D6CC48FC18 for ; Sun, 21 Dec 2008 22:27:55 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id mBLMSH1m018830 for ; Sun, 21 Dec 2008 14:28:17 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Sun, 21 Dec 2008 14:27:44 -0800 (PST) Date: Sun, 21 Dec 2008 14:27:44 -0800 From: Gary Kline To: freebsd-questions@freebsd.org Message-ID: <20081221222744.GA28185@thought.org> References: <20081221053407.GA87868@thought.org> <877i5unkx4.fsf@kobe.laptop> <1229854084.6392.52.camel@ethos> <20081221140658.GA24691@marge.bs.l> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081221140658.GA24691@marge.bs.l> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 22 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.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: Sun, 21 Dec 2008 22:27:56 -0000 On Sun, Dec 21, 2008 at 03:06:58PM +0100, Bertram Scharpf wrote: > Hi, > > Am Sonntag, 21. Dez 2008, 02:08:04 -0800 schrieb Gary Kline: > > On Sun, 2008-12-21 at 07:42 +0200, Giorgos Keramidas wrote: > > > On Sat, 20 Dec 2008 21:34:10 -0800, Gary Kline wrote: > > > > > > > > sed '8,10d'< file> newfile > > > > or is there a better way? > > > > > > keramida@kobe:/tmp$ sed -i '' -e '2d' foo > > > > > thanks much. it works just fine in-place. ...but i did made a separate > > copy, just in case;-) > > To make a copy, call > > $ sed -i .bak 8,10d myfile > > Be aware that the -i option is not portable. -> man sed /^STANDARDS yeah, i've been checking around: sed, even gsed. surprised that the berkeley sed is non-standard with some flag. [next thing i'll read is that berkeley did Not code half of unix.] 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: perl -pi.bak -e 's/OLDSTRING/NEWSTRING/g' file1 file2 fileN that i swiped somewhere. [?] last night i was up until the wee hours coding or extending a c++ program to assist in this stuff. while i really get off on hacking code, it's less of a thrill at 02:10, say:_) gary > > Consider Perl or > > $ ruby -i.bak -pe 'next if 8..10 === $.' x > > Bertram > > > -- > Bertram Scharpf > Stuttgart, Deutschland/Germany > http://www.bertram-scharpf.de -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org The 2.17a release of Jottings: http://jottings.thought.org/index.php