Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am used to grep being able to color the filename, the line number, and the match itself. These three ought to be different colors. This works flawlessly on a Linux terminal and even MinGW on Windows, but on OS X even if I set GREP_COLOR I can only get color on the matched result.

Is the version of grep packaged with the OS too old?

10.7.3 on MBA 13" with

share|improve this question
This still work? -->… – emgee May 2 '12 at 4:42
I just came from there. I did exactly what was described. Just one color got set. – Steven Lu May 2 '12 at 4:45
up vote 7 down vote accepted

As Ignacio already said, OS X grep is a bit outdated (it's version 2.5.1). You can install the latest GNU grep though.

As always, you can install most missing Linux tools on OS X through Homebrew, but its policy is not to offer duplicates for system tools. There's an alternative repository for these dupes, but you have to "tap" it first:

brew tap homebrew/dupes/

Then you can install the new grep (version 2.11 as of May 2012):

brew install homebrew/dupes/grep

Be aware that /usr/bin still comes first in your PATH, so you need /usr/local/bin/grep for the new version.

share|improve this answer
What's a nice way to get grep to run from the new location? an alias? – Steven Lu May 2 '12 at 22:14
@StevenLu, you may want to put /usr/local/bin before /usr/bin. e.g., you can do this globally by editing /etc/paths, or have your shell startup script (e.g., ~/.bash_profile) edit PATH to change the order. – Chris Page May 3 '12 at 6:20

Correct. Multiple colors were first supported in GNU grep 2.5.3.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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