统计网站 同一IP访问的次数及IP地址

[root@master ~]# awk '{ip[$1]++} END{for (i in ip) print i,ip[i]}' /var/log/httpd/access_log
192.168.116.1 6
192.168.116.128 100

$1是从日志中获取IP,将IP作为下标 存入数组 同一IP进行++相当于将ip[$1]作为一个变量 for循环遍历到的是IP
ip[i]打印出变量的数值

发布了5 篇原创文章 · 获赞 5 · 访问量 951

猜你喜欢

转载自blog.csdn.net/WEN_BK/article/details/105732197