Date: Sun, 21 Dec 2008 14:27:44 -0800 From: Gary Kline <kline@thought.org> To: freebsd-questions@freebsd.org Subject: Re: Sed question Message-ID: <20081221222744.GA28185@thought.org> In-Reply-To: <20081221140658.GA24691@marge.bs.l> References: <20081221053407.GA87868@thought.org> <877i5unkx4.fsf@kobe.laptop> <1229854084.6392.52.camel@ethos> <20081221140658.GA24691@marge.bs.l>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <kline@thought.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081221222744.GA28185>