我有一个 Apache 日志格式文件。示例字符串:
fj5020.inktomisearch.com - - [01/Oct/2006:06:35:59 -0700] "GET /example/When/200x/2005/04/27/A380 HTTP/1.0" 200 4776 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"
其中 4776 是以字节为单位的页面大小。我想按服务流量输出前 10 个 URL。我遇到了对每个唯一页面的所有大小求和的问题(页面的大小也可以是可变的)。关于如何在 Bash 或/和 AWK 中执行此操作有任何想法吗?
最佳答案
这对你有用吗?
awk '{a[$7]+=$10}END{for(x in a)print x, a[x]}' yourLogfile|sort -r -n -k2|head -n10
关于linux - Apache 日志 : Count top 10 URLs by bytes served,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7570112/