如何使用 awk 统计 服务器日志每个url的访问次数(排除搜索引擎)?


日志格式为:

   
  117.72.201.7 - - [30/Jun/2012:00:04:09 +0800] "GET /news/3186 HTTP/1.1" 200 19048 "http://www.xxx.com/xxxx/xxx" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2" -
 

如何统计分别统计出每个url的访问次数? 需要排除各个搜索引擎的记录。

awk shell

桃黒亭一门 12 years, 10 months ago

用sed删除搜索引擎的访问记录;
参照这个问题 @用SHELL如何统计排序WEB ACCESS LOG

   
  sed "/Baiduspider/d;/Googlebot/d;/Sogou web spider/d;" xxx.log|awk -F' ' '{print $7}'|sort | uniq -c | sort -k1,2 -nr > times.txt
 

糟糕这翔里有毒 answered 12 years, 10 months ago

Your Answer