列出 Apache access_log 中的前 404 个 URL

tyk*_*kho 7 grep logging http-status-code-404 apache-2.2

我正在寻找一个命令来从我的 apache access_log 中列出 10 或 20 个前 404 错误 URL。谁能帮我这个?

谢谢

car*_*son 7

假设正常的 access_log 格式应该这样做:

cat access_log | awk '{ if($9 == 404) { print $7 } }' | sort | uniq -c | sort -nr | head -10
Run Code Online (Sandbox Code Playgroud)

  • `sort -r` 按字母顺序倒序排序,因此它将在“2”之后放置“1”、“10”和“100”。您应该使用数字反向排序:`sort -nr`。 (3认同)