[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19990706: another GEMPAK raw data question
- Subject: 19990706: another GEMPAK raw data question
- Date: Fri, 09 Jul 1999 09:36:34 -0600
>From: address@hidden
>Organization: .
>Keywords: 199907091514.JAA29497
>Steve,
>
>After I figured out that awk on Solaris is old "awk" and
>won't accept -v, and used nawk instead..it works great.
>I wonder if you could help with an awk question, that I
>can't find the answer to in my awk book (a rather poor one).
>Since the data is transmitted so many times, I get a lot of
>repetitious data, is there a way to tell awk to only find
>the requested pattern a set number of times?, say two or
>three to allow for the "NIL" lines?
>
>Thanks
>Robert
>
>
Robert,
You can put a counter in, and increment it after a non-NIL
bulletin. Then test the counter on the original comparison line, eg:
#!/bin/csh -f
set ASTN=72403
set PART=PPDD
set FILE=/shemp/data/ldm/upperair/199907091?_upa.wmo
awk -v ASTN=${ASTN} -v PART=${PART} -v COUNT=0 \
'index($0,ASTN) != 0 && index($0,PART) != 0 && COUNT == 0 { print \
while(index($0,"=") == 0) \
{ getline; print $0 } \
if(index($0,"NIL") == 0) {COUNT = COUNT + 1} \
printf "\n" \
}' $FILE
The above will still print out NIL lines and only increment COUNT when
the "=" line doesn't have NIL in it. You can suppress the output of the
NIL lines in the top pattern matching line by adding "&& index($0,"NIL") == 0".
Steve Chiswell