UNIX cumulater

hi all

i want a script to get a cumulative item , data as following

realM,spain,win,night -----1
barca,spain,win,night  
realM,spain,lose,night ----2
realM,spain,win,night------3
realM,spain,lose,night -----4
realM,spain,lose,night-------5
barca,spain,lose,night
barca,spain,win,night
realM,spain,win,night-------6

to get output as

barca,spain,2win,1lose,night
realM,spain,3lose,3win,night

thanks a lot

i think its the same concept on uniq -c but in awk

try..

 
awk -F, '{if($3=="win"){A[$1","$2]++}else{B[$1","$2]++}}END{for(i in A){print i","A"win,"B"lose"}}' filename
1 Like

thanks alot,sorry, if i need the output as the following

barca,spain,2win,night     ---- 2 win and 1 lose  ----- drop lose 
realM,spain,3win,night

here we got the ($3) that counted more and if equal get the first one .

sorry if i dont know what comes in $3 as if its serial code