The best way to set up and use GNU Grep in macOS


The reply from nohillside wants updating as follows:

If grep was already put in by brew, take away grep first.

% brew uninstall grep

Then set up grep:

% brew set up grep

All instructions have been put in with the prefix "g".
If you have to use these instructions with their regular names, you
can add a "gnubin" listing to your PATH out of your bashrc like:
  PATH="/usr/native/decide/grep/libexec/gnubin:$PATH"
=º  /usr/native/Cellar/grep/3.3: 21 recordsdata, 880.7KB

Notice that you just do want to change the PATH. For instance, add to your .bashrc:

export PATH="/usr/native/decide/grep/libexec/gnubin:$PATH"

I needed to do the above on my mac when after brew improve my grep was now not accessible (it was put in beforehand with brew set up grep --with-default-names, and this selection just isn’t out there any extra).

This answer works as of Homebrew 2.1.1:

brew --version
Homebrew 2.1.1
Homebrew/homebrew-core (git revision 5afdd; final commit 2019-04-22)
Homebrew/homebrew-cask (git revision a5a206; final commit 2019-04-22)

This reply is predicated on the one from nohillside, with feedback from Jonathan Komar and scott m gardner.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles