-
Notifications
You must be signed in to change notification settings - Fork 3
Home
logfiles will be pleasant to watch...
Colorex is a tool developed by Scopart
Colorex display files or sdtin with pretty colors for matched patterns. if you don't specify files, stdin is used.
here is an output example:
if you have setuptools installed you can install colorex whith easy install on your terminal:
easy_install colorex
you can also download the archive and copy colorex script in your path (eg: /usr/local/bin/)
colorex [options] [file1] [file2] ...
--version show program's version number and exit
--help, -h show this help message and exit
--blue=BLUE, -b BLUE display BLUE pattern in blue
--red=RED, -r RED display RED pattern in red
--green=GREEN, -g GREEN display GREEN pattern in green
--yellow=YELLOW, -y YELLOW display YELLOW pattern in yellow
--magenta=MAGENTA, -m MAGENTA display MAGENTA pattern in magenta
--cyan=CYAN, -c CYAN display CYAN pattern in cyan
--bblue=BBLUE, -B BBLUE display BBLUE pattern in blue background
--bred=BRED, -R BRED display BRED pattern in red background
--bgreen=BGREEN, -G BGREEN display BGREEN pattern in green background
--byellow=BYELLOW, -Y BYELLOW display BYELLOW pattern in yellow background
--bmagenta=BMAGENTA, -M BMAGENTA display BMAGENTA pattern in magenta background
--bcyan=BCYAN, -C BCYAN display BCYAN pattern in cyan background
--blink=BLINK, -K BLINK display BLINK pattern blinking (not widely supported)
--bold=BOLD, -D BOLD display BOLD pattern in bold
--undrln=UNDRLN, -u UNDRLN display UNDRLN pattern underlined
--bisounours, -N display with random colors
Regular expressions are interpreted, so if you want to match a '*' or a '[' or any element of the regexp grammar you have to escape it with a backslash.
to display every word "ERROR" in red of foo.txt, type:
colorex --red ERROR foo.txt
to watch logfile.txt displaying "WARNING" in yellow and "INFO" in green:
tail -f logfile.txt | colorex -y WARNING --green INFO
exit with CTRL c
to display "(" and ")" contained in foo.txt in blue:
colorex -b '\(|\)' foo.txt
to diplay in red "FATAL" or "ERROR" and strings like [1234] or [4567] with red background, just type:
colorex -r 'ERROR|FATAL' -R '\[[0-9]{4}\]'
another case:
tail -f /var/log/syslog | colorex -G '[0-9]{2}:[0-9]{2}:[0-9]{2}' -b $(hostname) -M '\[[0-9]{1,5}\]'