For example, there are the following files Test.txt
1 134.102.173.43
2 134.102.173.43
3 134.102.171.42
4 134.102.170.9
To count the most frequently occurring IPs, you can take advantage of the following shell script:
Cat Test.txt | awk ' {print $} ' | Sort | uniq-c | Sort-n-R | Head-n 1
[Original] The most frequently counted IP
One is still very common, very practical, very simple command
Netstat-ntuactive Internet Connections (w/o servers) Proto Recv-Q send-Q Local Address Foreign address statetcp0 0 127.0.0.1:8152 127.0.0.1:4193time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4192time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4196time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4199time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4201time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4204time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4207time_waittcp0 0 127.0.0.1:8152 127.0.0.1:4210time_waittcp0 0 192.168.32.62:41682 192.168.47.27:5431time_waittcp0 0 192.168.32.62:41685 192.168.47.27:5431Time_waitnetstat-ntu | Tail-n +3|awk'{print $}'| Cut-d:-F1| Sort | uniq-c| Sort-n-R | Head-n58 127.0.0.12 192.168.47.27
Tail-n +3: Remove the two lines marked in red above.
awk ' {print $} ': 5 fields (5th column) with low data, indicated by blue above.
Cut-d:-F 1: Take the IP section in front of the blue section.
Sort: Sorts the IP parts.
UNIQ-C: Prints the number of occurrences of each repeating row. (and remove duplicate lines)
Sort-n-R: In reverse order in which repeated rows appear.
Head-n 5: Take the first 5 bits of IP
Use the most frequently occurring IP in the shell script statistics file