Skip to content

Instantly share code, notes, and snippets.

@trolologuy
Created January 27, 2021 13:51
Show Gist options
  • Save trolologuy/4b5aa77887ad0960254f43212fc7cad6 to your computer and use it in GitHub Desktop.
Save trolologuy/4b5aa77887ad0960254f43212fc7cad6 to your computer and use it in GitHub Desktop.
A simple bash oneliner to parse the server's access.log file to split by http error codes and count them individually. By default it browses `/var/log/access.log` and limit's the search on the last `5000` lines.
tail -n 5000 /var/log/access.log | awk '{print $9}' | sort | uniq -c | sort -nr | head -n15
# Example of output:
# 2625 499
# 1433 500
# 569 200
# 243 401
# 108 404
# 16 301
# 6 302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment