アクセスログ解析

アクセスログ例

xxx.xxx.xxx.xxx - - [30/Dec/2015:03:04:54 +0900] "GET /favicon.ico HTTP/1.1" 200 19508 "http://53ningen.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
xxx.xxx.xxx.xxx - - [30/Dec/2015:03:04:55 +0900] "GET / HTTP/1.1" 200 19496 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"

ある特定の時間のアクセス数をカウントする

cat access.log | grep -P -o '30/Dec/2015:15:5\d{1}' | sort | uniq -c
      2 30/Dec/2015:15:51
      1 30/Dec/2015:15:52
      1 30/Dec/2015:15:53
      2 30/Dec/2015:15:54
      1 30/Dec/2015:15:55
      1 30/Dec/2015:15:57
      1 30/Dec/2015:15:58
      2 30/Dec/2015:15:59