Terminal highlight error when compiling with a make file

5,949

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'
Share:
5,949

Related videos on Youtube

Nick
Author by

Nick

Updated on September 18, 2022

Comments

  • Nick
    Nick over 1 year

    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?

    • Scott - Слава Україні
      Scott - Слава Україні about 11 years
      (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?
    • nhinkle
      nhinkle about 11 years
      @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).
    • Scott - Слава Україні
      Scott - Слава Україні about 11 years
      @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 - Слава Україні
      Scott - Слава Україні about 11 years
      @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 - Слава Україні
      Scott - Слава Україні about 11 years
      @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!