On Tue, Jul 03, 2001 at 11:10:10AM +1000, Terry Collins wrote:
> Scott Howard wrote:
> 
> > That said, you'd be better doing it in a way which wouldnt load anything
> > into memory, like awk (presuming positive numbers)
> > 
> > awk ' $2>A { A=$2 } $3>B { B=$3} END { print A,B } '
> 
> Yep, that was what I was after.
>  
> The file consisted of 134,069 entries like
> 
> PD 456,78
> 
> in a HPGL plot file. So culling the starting and ending lines, the :,$
> s/,/ / to replace the comma by a space and running ScoTt awk line
> produced what I needed; the input to the IP paramters (bottom left and
> top right of the plot area.

Why didn't you say so!! :)

nawk -F',| ' 
'!/^PD/{continue}$2<X1||!X1{X1=$2}$2>X2||!X2{X2=$2}$3<Y1||!Y1{Y1=$3}$3>Y2||!Y2{Y2=$3}END{printf"(%s,%s)
 (%s,%s)\n",X1,Y1,X2,Y2}'

will do the lot for you - including looking after the space/comma, the
start and end lines, and it will now even handle negative numbers!
(Under Solaris you need to use nawk to get this to work. Under Linux
normal awk should work as from memory awk/nawk/gawk are all the same).

  Scott.

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to