I'd like to be able to tail the output of a server log file that has messages like:
INFO
SEVERE
etc, and if it's SEVERE
, show the line in red; if it's INFO
, in green. What kind of alias can I setup for a tail
command that would help me do this?
Best Answer
Try out multitail. This is an übergeneralization of
tail -f
. You can watch multiple files in separate windows, highlight lines based on their content, and more.The colors are configurable. If the default color scheme doesn't work for you, write your own in the config file. For example, call
multitail -cS amir_log /path/to/log
with the following~/.multitailrc
:Another solution, if you're on a server where it's inconvenient to install non-standard tools, is to combine
tail -f
with sed or awk to add color selection control sequences. This requirestail -f
to flush its standard output without delay even when its standard output is a pipe, I don't know if all implementations do this.or with sed
If your sed isn't GNU sed, replace
\o033
by a literal escape character and remove--unbuffered
.Yet another possibility is to run
tail -f
in an Emacs shell buffer and use Emacs's syntax coloring abilities.