Linux – Terminal highlight error when compiling with a make file

greplinuxputtysshterminal

I have a simple make file and I want to highlite the word or line that contains "error:" to make it easier to see.

I am SSH via Putty to the linux machine which may cause a problem but currently I have tried to grep with a pipe but it doesn't highlight anything:

grep -E --color 'error|$' | make

It outputs this:

How Can I highlite the line or word error in Console output? And could I make it into an Alias so I wouldn't have to grep pipe each time?

Best Answer

in grep there are 3 color options available to you:

--color=auto
--color=always
--color=never

Try specifying =always

From grep man page:

    --colour[=WHEN], --color[=WHEN]
          Surround  the matching string with the marker find in GREP_COLOR
          environment variable. WHEN may be 'never', 'always', or 'auto'

Lastly, you can specify the color parameter in a grep-specific environment variable. Then, you don't have to enter it in the command line.

$ export GREP_OPTIONS='--color=always'
Related Question