Last night I found myself desperate to read the output of tail but looking for specific content. (Basically tailing a log file and needing to have the fields pop out at me.)

There’s no easy colorize command in linux so I did some digging, found something similar and modified it. (This is based on Kenny Moen’s blog entry about baretail on unix.) Anyway, the following perl script will allow any content to be highlighted using a simple regex and a pipe.

For example, to highlight an entire line wherever named is listed:
tail -f /var/log/messages | colorize –highlight “blue:.*named.*”

Or to highlight the incoming interface and outgoing interface on a firewall log with red for the inside and green for the outside:
tail -f /var/log/messages | colorize –highlight “red:w+=eth0” –highlight “green:w+=eth1”

Enjoy!