Skip to content

Instantly share code, notes, and snippets.

@raminv80
Created July 24, 2015 07:40
Show Gist options
  • Save raminv80/f1aa5acf6ba5f77b8522 to your computer and use it in GitHub Desktop.
Save raminv80/f1aa5acf6ba5f77b8522 to your computer and use it in GitHub Desktop.
Easily view paper trail log files
GNU nano 2.3.1 File: search.sh
#!/bin/sh
# Linux users have to change $8 to $9
awk '\
function red(s) {
printf "\033[1;31m" s "\033[0m "
}
function green(s) {
printf "\033[1;32m" s "\033[0m "
}
function blue(s) {
printf "\033[1;34m" s "\033[0m "
}
function severity(s){
IGNORECASE = 1
if(s ~ /error/) {
red(s)
}else{
green(s)
}
}
{
IGNORECASE = 1
if ($9 ~ /production/) {
printf ("%s %s $s",blue($2), severity($8),$5);
for(i=10;i<NF;i++){
printf "%s ",$i
}
printf "\n"
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment