抓取访问web服务器(本机)次数排在前5的ip地址-----cut,sort,uniq的应用)

当前主机为web服务器,请抓取访问web服务器次数排在前5的ip地址
[root@node1 logs]# cut -d - -f 1 /etc/httpd/logs/access_log| sort -n|uniq -c | sort -nr|head -n 5
39 172.25.254.204
24 172.25.254.120
10 172.25.254.220

在统计重复的时候,如果相同的数字不挨着,则无法统计成重复的,所有先进行排序,排序完所有的相同的数字会挨在一起

猜你喜欢

转载自blog.csdn.net/ninimino/article/details/111397374