Sed question

Gary Kline kline at thought.org
Sun Dec 21 22:27:56 UTC 2008


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 at thought.org> wrote:
> > > >
> > > > sed '8,10d'< file> newfile
> > > > or is there a better way?
> > > 
> > >   keramida at 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 at 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



More information about the freebsd-questions mailing list