Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created October 31, 2017 04:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save coreymcmahon/f4856097fbc6a745a6072b398c4a0c05 to your computer and use it in GitHub Desktop.
Save coreymcmahon/f4856097fbc6a745a6072b398c4a0c05 to your computer and use it in GitHub Desktop.
Colorize Nginx access log
#!/usr/bin/env bash
tail -f /var/log/nginx/access.log | awk '
/" 2/ {print "\033[32m" $0 "\033[39m"; next;}
/" 3/ {print "\033[37m" $0 "\033[39m"; next;}
/" 4/ {print "\033[33m" $0 "\033[39m"; next;}
/" 5/ {print "\033[31m" $0 "\033[39m"}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment