I need help on awk [closed]
Solution 1:
$ awk 'BEGIN {FS=OFS="|"}
{k=$1; c[k]++; c2[k,$2]++; c3[k]+=($3==1); c4[k]+=($4==1)}
END {for(k in c)
print k,c[k],c2[k,1]+0,c2[k,2]+0,c2[k,3]+0,c3[k],c4[k]}' file
m1|3|1|1|1|2|3
m2|3|2|1|0|1|3
m3|2|1|1|0|1|2
counts only "1"s in the 3rd and 4th columns