Em is a terminal tool that prints FILE(s), or standard input to standard output and highlights the expressions that are matched the PATTERN.
The expression will be highlighted iff the terminal is ANSI-compatible. This criterion is met by most popular terminal emulators on Linux, Unix and MacOS.
Em is a small script written in Python without any further dependencies but things that are shipped with Python 2.7, Python 3.2 or above. Quick installation:
$ [sudo] pip install em
For some reason the Python 2.6 support has been added, but
argparse is required and will be installed from PyPI.
Em is cool and easy to use. The most practical usecase for me:
$ tail -f /path/to/log | em "ERROR" | em "iphone:" -f green
The example above highlights all occurrences of «ERROR» in red and all occurrences of «iphone:» in green when watching the log.
But you can use em in the following way:
$ em "ERROR|CRITICAL" /path/to/log
which prints the log and highlights all occurrences of «ERROR» or «CRITICAL» in red.
Here is a command line interface of Em:
usage: em [OPTION]... PATTERN [FILE]... Em is a terminal tool that prints FILE(s), or standard input to standard output and highlights the expressions that are matched the PATTERN. positional arguments: PATTERN a pattern to highlight FILE search for pattern in these file(s) optional arguments: -f FORMAT, --format FORMAT a color to highlight matched expressions -i, --ignore-case ignore case distinctions -l, --line-mode highlight entire line -v, --version show program's version number and exit -h, --help show this help message and exit With no FILE, or when FILE is -, read standard input. The FORMAT option may be one of: BOLD, UNDERLINE, [ON]GREY, [ON]RED, [ON]GREEN, [ON]YELLOW, [ON]BLUE, [ON]MAGENTA, [ON]CYAN or [ON]WHITE. Default is RED.
The CLI is clear, but some option descriptions are below:
||Highlight matched PATTERN with that color. (default: RED)|
||Case insensitive search for the PATTERN.|
||Highlights the entire line if PATTERN was found in the line.|