Created
October 14, 2011 20:25
-
-
Save mutsuda/1288230 to your computer and use it in GitHub Desktop.
Colored tail -f version: With this shellscript you'll be able to see your system/server logs with personalized colors in personalized lines containing certain words.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage | |
{ | |
echo "usage: supertail -f file [-bl word1 -m word2 -g word3 -w word4 -bk word5 ...] " | |
echo "bl=blue, bk=black, g=green, m=magenta, r=red, c=cyan, w=white, y=yellow, etc." | |
} | |
while [ "$1" != "" ]; do | |
case $1 in | |
-f | --file ) shift | |
filename=$1 | |
;; | |
-bl| --blue ) shift | |
blueword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;44m$&\e[0m/g;' | |
;; | |
-m | --magenta ) shift | |
magentaword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;45m$&\e[0m/g;' | |
;; | |
-bk| --black ) shift | |
blackword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;40m$&\e[0m/g;' | |
;; | |
-r | --red ) shift | |
redword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;41m$&\e[0m/g;' | |
;; | |
-g | --green ) shift | |
greenword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;42m$&\e[0m/g;' | |
;; | |
-y | --yellow ) shift | |
yellowword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;43m$&\e[0m/g;' | |
;; | |
-c | --cyan ) shift | |
cyanword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;46m$&\e[0m/g;' | |
;; | |
-w | --white ) shift | |
whiteword=$1 | |
perl=$perl's/.*\b('$1')\b.*/\e[1;37;47m$&\e[0m/g;' | |
;; | |
* ) usage | |
exit 1 | |
esac | |
shift | |
done | |
sudo tail -f $filename | perl -pe $perl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wtf, super useful