Question
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 Terminal.app.
Answer
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.
Check more discussion of this question.