我有一个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)"
Run Code Online (Sandbox Code Playgroud)
其中4776以字节为单位提供页面大小.我想按服务流量输出前10个网址.我坚持总结每个唯一页面的所有大小的问题(页面的大小也可以是变量).有任何想法如何在Bash或/和AWK中做到这一点?
这对你有用吗?
awk '{a[$7]+=$10}END{for(x in a)print x, a[x]}' yourLogfile|sort -r -n -k2|head -n10
Run Code Online (Sandbox Code Playgroud)