How to sort,uniq and display line that appear more than X times

后端 未结 2 1749
野性不改
野性不改 2021-02-07 13:02

I have a file like this:

80.13.178.2
80.13.178.2
80.13.178.2
80.13.178.2
80.13.178.1
80.13.178.3
80.13.178.3
80.13.178.3
80.13.178.4
80.13.178.4
80.13.178.7
         


        
2条回答
  •  灰色年华
    2021-02-07 13:17

    With pure awk:

    awk '{a[$0]++}END{for(i in a){if(a[i] > 2){print i}}}' a.txt 
    

    It iterates over the file and counts the occurances of every IP. At the end of the file it outputs every IP which occurs more than 2 times.

提交回复
热议问题