linux - Apache 日志 : Count top 10 URLs by bytes served

标签 linux bash awk

我有一个 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/

相关文章:

Python 检索 RUID?

php - UTF-8贯穿始终

git - __git_ps1 在内核树中非常慢

bash - 在 Emacs 中的脚本中着色/缩进脚本

linux - Masscan输出仅获取ip:port并保存到文件中?

linux - 使用 shell 命令从 yum 命令历史记录中检索补丁名称

c++ - 在多线程环境中使用Mysql++的问题

Linux Dialog 包参数插入 for/while 循环?

bash - 从 zsh 进入 bash 时如何加载 ~/.bash_profile?

bash - Heredoc 不保留空行