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:
brew install grep
This will install ggrep
so as not to override your existing grep
. If you want to change that, see the info message:
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like:
PATH="$(brew --prefix)/opt/grep/libexec/gnubin:$PATH"
Further, you can enable a color option and exclude some directories by default, which may make it more useful:
alias grep="ggrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
Add this to your ~/.bash_profile
or whatever shell configuration you are using.