Color my logs

I was looking for a simple way to colorize text such as output of a tail from within my bash shell. I wanted something simple as KISS, of course.

lwatch seems to be tailored for logfiles. ccze is a bit of overkill. MultiTail while sure a nice tool just did not behave as expected, and one has to define color schemes in separate files.

Luckily, I remembered that it is pretty easy to colorize the shell's prompt or any echo lines. So, I quickly checked if a sed command like

sed -e "s/\(my regex\)/$color\1$resetcolor/g"

actually works if colors are stored in environment variables. And it does :-)

Thus, I wrote a small script mycolorize that allows me to do something like

tail -f procmail.log | mycolorize red '^From: .*' blue '^ Subject: .*'

For details see A simple colorize for the shell