install gnu grep on mac

Shell
brew install grep --with-default-names 

# the code above doesnt work anymore, so use the following:

brew install grep

# to use GNU, use ggrep rather than grep

ggrep -V

# Will now return GNU
Source

Also in Shell: