Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jan 2004 04:19:04 -0800
From:      "Lee Mx" <lee_ver_mx@hotmail.com>
To:        kline@thought.org
Cc:        freebsd-questions@freebsd.org
Subject:   Re: stumped... .
Message-ID:  <BAY8-F19VjBUKv1pKcq000206e6@hotmail.com>

next in thread | raw e-mail | index | archive | help

> > > On Sat, 17 Jan 2004, Gary Kline wrote:
> > >
> > > >
> > > > I've written scores of scripts to hack text files, but this
> > > > one has me dead in the water.
> > > >
> > > > How can I delete all lines from /^PATTERN to EOF??
> > > >
> > > > ed - <<foo
> > > >
> > > > /^PATTERN
> > > > (.,$)d
> > > > w
> > > > q
> > > > foo
> > > >
> > > > or anything else I've tried doesn't do it.  I could do it in
> > > > C/C++,but c'mon... !  Any solutions in sed, perl, or ed/ex?
> > >
> > > Well, you didn't mention awk, but...
> > >
> > >
> > > awk '$0 ~ /^PATTERN/ {x=1}; {if (x!=1) print $0}' < foo > bar
> > >
> >
> > Wouldn't it be neater to do
> >
> >   nawk '/^PATTERN/ { exit } ; { print }'

Couldn't sed '/^PATTERN/,$d' < foo > bar be a bit faster?

_________________________________________________________________
Check out the new MSN 9 Dial-up — fast & reliable Internet access with prime 
features! http://join.msn.com/?pgmarket=en-us&page=dialup/home&ST=1



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BAY8-F19VjBUKv1pKcq000206e6>