首页 > 代码库 > 访问日志access.log统计ip和每个地址访问的次数

访问日志access.log统计ip和每个地址访问的次数

access.log:

192.168.1.247 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.246 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.245 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.243 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.247 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.247 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.245 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.246 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.246 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.247 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.245 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.245 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.246 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.243 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"

192.168.1.247 - - [02/[ul/2015:23:44:59 [0800] "GET /[HTTP/1.1 200 19"


答案:


[wangyuanyuan@vpn shell]$ awk ‘{print $1}‘ access.log |sort -n|uniq -c|sort -rn|head

      5 192.168.1.247

      4 192.168.1.246

      4 192.168.1.245

      2 192.168.1.243




本文出自 “linux” 博客,转载请与作者联系!

访问日志access.log统计ip和每个地址访问的次数