How to get the validate the count with the group by data in unix
问题 I have a list of records as following Source: a,yes a,yes b,No c,N/A c,N/A c,N/A d,xyz d,abc d,abc Output: a, Yes 2 b, No 1 c, N/A 3 d, xyz 1 d, abc 2 c, N/A "File is not correct" Here 'Yes' and 'No' are the acceptable words, If any other word count is greater than the 'Yes' or 'No' word count for an individual $1 value then we have issue a statement like "file is not good" I have tried the below script awk -F, '{a[$1]++;}END{for (i in a)print i, a[i];}' filetest.txt 回答1: If you are not