notexcitex

Log triage with awk and sort

18 November 2026

When a web server misbehaves, the first question is usually who is hitting it and with what. A combined access log already answers that; it just needs counting.

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head

Swap $1 for $7 to count paths instead of clients, or for $9 to see status codes. For a time window, filter first:

awk '$4 >= "[18/Nov/2026:10:00" && $4 < "[18/Nov/2026:11:00"' access.log

The string comparison works only because the timestamp sorts lexically within a single day. Across days, convert to epoch seconds first.