You will need to add the following to your ~/.bash_profile: PATH="$(brew -prefix coreutils)/libexec/gnubin:$PATH" If this is too much of a hassle to type every time, you can add a "gnubin" directory to your PATH and just call GNU sed with sed. So, after installing the Coreutils, if you want to use GNU sed, type gsed
However, so as not to "override" default OS X binaries, they will be prefixed with g by default. These will provide you with sed, date, printf, wc and many other tools that ship with GNU/Linux, but not OS X. Once you've installed Homebrew, you can type brew install coreutilsĪnd install the GNU Coreutils.
XSHELL FOR MAC OS HOW TO
You can wire this up so that it only sets your PATH that way if you are starting an interactive shell you can google how to do this with bash or ask another question on SU (or search for it, since it's probably been asked before) if you want to do that.Īn example of such an environment is Homebrew which for example has GNU sed among other things. What you can do is install an environment that installs the GNU utilities in another directory without overwriting the defaults, and then adjust your PATH environment variable so that it gives priority to commands found within the GNU directory before it even searches the system directories. Especially if you use some software that was "ported" to Mac OS X after being originally designed to run on Linux or BSD, as these types of programs are more likely to rely on shell scripts and system commands as opposed to calling OS X APIs. So if you just wipe out the system commands and replace them with GNU equivalents that have incompatible behavior or command line arguments, it will probably break something. The reason is that many system administration scripts and third-party packages probably rely on these commands to behave the way they do out of the box on OS X. In the general case, you can't (or shouldn't) replace the default commands at all.