grep with color and context

By gill, 8 November, 2020

GNU grep on Linux provides some interesting options. When you search for text in a log file, you can also highlight the text in color, and display two lines of context (the two lines preceding and succeeding the line containing the search expression). For example:
# grep --color -C 2 -E "res=failure" /var/log/audit/audit.log