stumped... .

Gary Kline kline at thought.org
Sat Jan 17 21:17:23 PST 2004


On Sun, Jan 18, 2004 at 03:14:50PM +1030, Rob wrote:
> David Fleck wrote on Sunday January 18, 2004:
> 
> 
> > 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 }'
> 
> ?


	Seems like this takes fewer keystrokes...  I don't know
	much awsk, but is there a way of feeding awk a cmd if
	the cont returns true?  Say:

	cmd1 | awk '{print $9}' == 'foo.c' 
	then
		echo "Found foo.c"
		mv foo.c ~/C_file
	END


	it's mostly like a perl hack, tho.

	anyway, thanks, gents,

	gary






-- 
   Gary Kline     kline at thought.org   www.thought.org     Public service Unix



More information about the freebsd-questions mailing list