For Programmers: Free Programming Magazines  


Home > Archive > AWK > February 2008 > Re: compare values in the same field in consecutive rows--and store









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: compare values in the same field in consecutive rows--and store
Ed Morton

2008-01-24, 7:02 pm



On 1/24/2008 12:53 PM, z.entropic wrote:
> I know it's a pretty basic question for true (g)awkers, but I've spent
> enough time today to try to make it work... I need your help...
>
> Here is the problem: I'd like to scan large data files, find
> consecutive lines in which a given field has a particular value,
> extract a value in another field and store it in an array for
> subsequent calculation.
>
> An example: if field $4 == 7 in the n-th row, and field $4 == 8 in the
> n+1st row, store the value of field $10 in array[n].


Depending on what you really mean above, either this:

awk -v f=4 '$f==(p+1){array[NR]=$10} {p=$f}' file

or this:

awk -v f=4 '($f==8)&&(p==7){array[NR]=$10} {p=$f}' file

should do it.

Ed.


Jenna

2008-01-26, 10:09 am

Nikki Cox and Olsen Twins Vibrating In Slits!
http://www.diarydiscount.com/Play?watch=726648
Xcrazeexbabex

2008-02-14, 4:46 am

matur epono]fat chick sgetting XXXXed[/URL]
funnyfatchicks fatc hix fatchicksneedloveto asianbang hairymature fat li pvideo fatkidvideo fat chickm ovies fattychick lingeri eladies fatb lack chicks bigbang fat whitec hick matureo lder woman ho tmature freevideos imf at music video thre efat chicks on a diet chow yunf at movies XXXX afat chick maturel esbian no fatc hicks free xxx video trailesr Tepmarmen

thre efat chicks]pics o ffat chicks[/URL]
my bi gfat independent movie maturebitches fatsc hicks fat gir lvideos imf at video free fat girlv ideos boatbang XXXX af at chick fa tgirl fatchickXXXXing fat man and little bo ymovie matur easian mature olde rwoman fatchicksinbikinis maturev ideos pictures o ffat chicks weird al fa tvideo no fat chickst shirt chicksass uglyfatchick fatw hite chicks obesechick sxey cams
matur emoms]peter griffin no fa tchicks[/URL]
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com