1

Help with awk in counting characters based on a column

view story
linux-howto

http://www.unix.com – Hello, I am using Awk in UBUNTU 12.04. I have a file as follows with 2172 rows and 44707 columns. ABO and GPO are the names of my populations. Code: ABO_1  1  2 ABO_1  1  2 ABO_2  1  1 ABO_2  1  2 GPO_1  1  1 GPO_1  2  2 GPO_2  1  0 GPO_2  2  0 I want to count the number of 1s and 2s in each population ignoring 0s if there is any but printing 0 if there is no 1 or 2 and have an output like this: Code: 4 0 2 2 1 3 1 1 Where 4 0 is the number of "1s" and "2s" in the second colum (HowTos)