Code Comments
Programming Forum and web based access to our favorite programming groups.I need to process a search of an array, locating the nth occurrence of the
search and only printing that particular record.
The following will locate the criteria and print, but only the first
occurence.
nawk '$1 == "RTOUT" {print $0, exit}' ${inputF} > ${outputF}
Any help on skipping the first occurence, locating the nth and only
printing that record?
Any suggestions would be appreciated,
groblela
Post Follow-up to this messagegroblela <lee.grobleski@nospam.wpafb.af.mil> wrote:
> I need to process a search of an array, locating the nth occurrence of the
> search and only printing that particular record.
> The following will locate the criteria and print, but only the first
> occurence.
>
> nawk '$1 == "RTOUT" {print $0, exit}' ${inputF} > ${outputF}
>
> Any help on skipping the first occurence, locating the nth and only
> printing that record?
>
> Any suggestions would be appreciated,
> groblela
Use a counter. If counter reaches 'n', then print.
--
William Park <opengeometry@yahoo.ca>
Open Geometry Consulting, Toronto, Canada
Post Follow-up to this messageOn Fri, 10 Sep 2004 10:29:18 -0400 in comp.lang.awk, "groblela"
<lee.grobleski@nospam.wpafb.af.mil> wrote:
>I need to process a search of an array, locating the nth occurrence of the
>search and only printing that particular record.
>The following will locate the criteria and print, but only the first
>occurence.
>
>nawk '$1 == "RTOUT" {print $0, exit}' ${inputF} > ${outputF}
>
>Any help on skipping the first occurence, locating the nth and only
>printing that record?
nawk -vN=5 '$1 == "RTOUT" { if (++cnt == N) { print $0; exit } }'
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian.Inglis@CSi.com (Brian[dot]Inglis{at}SystematicSW[dot]a
b[dot]ca)
fake address use address above to reply
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.