Consider I have a following file..
1 a
1 b
1 a
1 c
1 a
2 a
2 d
2 a
2 d
I want to have a histogram within a bucket… for example if bucket is 1 then the output will be
a 3
b 1
c 1
a 2
d 2
for bucket 2… we have
a 5
b 1
c 1
d 2
I want to do it with awk and I literally stuck…
here is my code:
awk '
{A[$1]} count [$2]++
{for(i in A) {print i,A[i]}
}' test
Any help?
Thanks,
Amir.
Edit Adding a size_of_bucket variable.