1

I would like to find common values from multiple files and corresponding counts of appearance using awk. I have, say four files such as: input1, input2, input3, input4:

input1:   input2:   input3:  input4
AA         AB        AA      AC 
AB         AC        AC      AF
AC         AF        AF      AD
AD         AG        AH      AH 
AF         AH        AK      AK 
                             AI

I would like the answer to be:

Variable:    Count
AA             2
AB             2
AC             4
AD             2
AF             4
AH             3
AK             2
AI             1

Any comments, please !!

4

1 回答 1

3
awk '{a[$0]++}END{for(x in a)print x,a[x]}' input*

使用您的输入,输出将是:

AA 2
AB 2
AC 4
AD 2
AF 4
AG 1
AH 3
AI 1
AK 2
于 2013-07-30T22:55:04.370 回答