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?

  • (1) Could you possibly have copied and pasted a few representative lines from the screen? Yes, a picture is worth 1000 words, yada, yada, yada, but that’s a lousy picture –– looking at it hurts my eyes. (OK, that’s partly my problem.) (2) Am I missing something? What do you expect to accomplish by piping grep into make? You want to take the output from make and do something with it, right? Doesn’t piping make into something seem to be a more useful approach? – Scott Mar 21 '13 at 2:50
  • @Scott the picture is fine, it's just scaled to fit into the width of the webpage. If you open the image in a new tab you'll see it at its original size. I edited the question to make the image clickable, but you can always right-click and choose "view image" or "open image in new tab" (depending on the browser). – nhinkle Mar 27 '13 at 4:08
  • @nhinkle: (1) The image may be fine, especially if we look at the secondary meaning of “fine”: “very small” (as in “fine print”) or “very thin or slender” (as in “fine thread”) [Merriam-Webster, “dictionary.com”], but my vision is maybe a little worse than 20/20. I looked at the image full size last week, and I did again just now, and I still have trouble reading it. – Scott Mar 27 '13 at 21:29
  • @nhinkle: (2) I stand by my implication that the signal-to-noise ratio is very low. Show one status message, one warning, and one error message, and you’ve illustrated all that you need to illustrate –– and they don’t have to be > 120 characters long. – Scott Mar 27 '13 at 21:29
  • @nhinkle: (3) Thanks for adding the hyperlink, but I beg to differ with your claim «you can always right-click and choose “view image” or “open image in new tab” (depending on the browser).». I’m a caveman; I just recently upgraded from IE8 to IE9, and neither of those browsers has either of those commands (see IE9 image). (4) +1 for the avatar. Live long and prosper! – Scott Mar 27 '13 at 21:30

in grep there are 3 color options available to you:


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'

The command should look something like the following

make 2>&1 | grep -E --color=always 'error|$'

This redirects the stderr stream from make to stdout. The '$' in the grep matches every line so that you see all output. Only the text 'error' will be highlighted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.