Hi Gurus,
I have a file
1|usa|hh
2|usa|ll
3|usa|vg
4|usa|vg
5|usa|vg
6|usa|vg
7|usa|ll
8|uk|nn
9|uk|bb
10|uk|bb
11|kuwait|mm
12|kuwait|jkj
13|kuwait|mm
14|dubai|hh
I want to group by last two columns and get the last two recs and count.
output should look like :
dubai hh 1
kuwait jkj 1
kuwait mm 2
uk bb 2
uk nn 1
usa hh 1
usa ll 2
usa vg 4
I tried something like this but this doesnt give the right counts
awk -F"|" '{col[$2,$3]=NR} END {for (i in col) print i, col[i]}' new.txt | sort
dubaihh 14
kuwaitjkj 12
kuwaitmm 13
ukbb 10
uknn 8
usahh 1
usall 7
usavg 6
Can any of the Unix Gurus help.
It has been posted earlier but I have modified it a bit.
Any suggestion is very much appreciated.
Thanks
Sumeet