One thing that bugs me about the bsd grep that comes with mac osx is that it doesn't offer you the -P flag. The -P flag will let you use the pcre engine in your regex matches, which is 100x more awesome than using the posix regex of egrep.
Not only that, but did you know gnu grep is significantly faster than the default bsd version? Go ahead and read Why is Gnu Grep So fast? where the author of gnu grep himself chimes in to explain why. Lots of nerdy tidbits in there.
You can install gnu grep on your mac very easily using brew. If you don't have brew you can install it following these instructions.
Installing gnu grep:
All done!
Not only that, but did you know gnu grep is significantly faster than the default bsd version? Go ahead and read Why is Gnu Grep So fast? where the author of gnu grep himself chimes in to explain why. Lots of nerdy tidbits in there.
You can install gnu grep on your mac very easily using brew. If you don't have brew you can install it following these instructions.
Installing gnu grep:
# Enable dupe and install
brew tap homebrew/dupes
brew install homebrew/dupes/grep
# Install the perl compatible regular expression library
brew install pcre
# Add the symlink to a place in $PATH ln -s /usr/local/Cellar/grep/2.14/bin/ggrep /usr/bin/ggrep
# Add an alias
alias grep="ggrep" # Verify you got it! $ grep --version
grep (GNU grep) 2.14 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
# If you want it to be permanent, you can add the alias line to your ~/.bash_profile
# You probably want the alias to stick after reboots
echo 'alias grep="ggrep"' >> ~/.bash_profile
All done!
