Skip to content

Instantly share code, notes, and snippets.

@dmgig
Last active August 29, 2015 14:13
Show Gist options
  • Save dmgig/56e8bbb1fb16cc6d00e2 to your computer and use it in GitHub Desktop.
Save dmgig/56e8bbb1fb16cc6d00e2 to your computer and use it in GitHub Desktop.
awk: colorize output
tail -n 5000 -f /var/log/requests.log | awk '
/FAIL$/ {print "\033[30m" $0 "\033[0m"} # black
/(\/delete.php)/ {print "\033[31m" $0 "\033[0m"} # red
/(\/move.php)/ {print "\033[32m" $0 "\033[0m"} # green
/(\/request.php)/ {print "\033[33m" $0 "\033[0m"} # yellow
/(\/change.php)/ {print "\033[34m" $0 "\033[0m"} # blue
/(\/part.php)/ {print "\033[35m" $0 "\033[0m"} # magenta
/(\/process.php)/ {print "\033[36m" $0 "\033[0m"} # cyan
/NO AFFECTED ROWS$/ {print "\033[37m" $0 "\033[0m"}' # white
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment