利用shell脚本统计文件中出现次数最多的IP

比如有如下文件test.txt

1  134.102.173.43

2  134.102.173.43

3  134.102.171.42

4  134.102.170.9

要统计出现次数最多的IP可以利用以下shell脚本:

cat test.txt | awk '{print $2}' | sort | uniq -c | sort -n -r | head -n 1

posted @ 2014-09-02 13:17  Richard Zhong  阅读(6276)  评论(0编辑  收藏  举报