13 Also note that if you just want to look for one matching regex, GNU grep with. What I would like to do is craft something that would highlight WARN in yellow and ERROR in red, and MicroKernel in green. I tried just piping grep --color=auto multiple times, but the only color that survives is the last command in the pipe.
Is there a one liner to do this? Or even a many-liner? When facing such situations, the first thing we should do is to check if the program feeding tail allows us to enable colors even when writing to a pipe. This is the case of ls and grep: By using the -color=always option, those programs will produce the necessary escape codes even when they write to a pipe. How do you grep in color? Learn how to colorized grep output with highlighting feature for ease of searching on Linux, macOS, or Unix.
To use a Color GREP to only highlight matched patterns but not otherwise change the output: grep --color=always -e "^" -e "hello" testfile The first pattern will match all lines (all lines will be printed) the second pattern (and any following patterns) cause the matched text to be highlighted in color. Since the first pattern matches all lines but does not match on a printable character, it. Tail it with color So, when you tail too many files and you don't have time to configure your shell with custom coloring there is a simple way to tail with color.
It's a simple and basic approach to see some colors on the lines you were searching for. tail -f *.log grep --color=always ' ==>.+. If I use two consecutive grep commands, e.g.: echo "foo bar" grep foo grep bar Then the first pattern ("foo") is not highlighted.
In fact, it seems that grep removes color codes from its input. Explore related questions command. There is a simlar question in Preserve ls colouring after grep'ing but it annoys me that if you pipe colored grep output into another grep that the coloring is not preserved.
As an example grep --color WORD * grep -v AVOID does not keep the color of the first output. But for me ls grep FILE do keep the color, why the difference?