This is very easy , but I`m struggling .. please help modify my script,
I want to count the number of h and n , from the second column group by the first. The second column is binary, can only have h and n.
Desired output
My try
I want to count the number of h and n , from the second column group by the first. The second column is binary, can only have h and n.
Code:
a h
a h
a n
a n
a h
b h
b h
b h
b h
b h
c n
c h
c h
c h
c h
Code:
h n
a 3 2
b 5 0
c 4 1
My try
Code:
awk '{A[$1]+=$2}END{for (i in A) print i,A[i]}' file