To use STDBUF from Homebrew's coreutils

You have to alter your path adding coreutils dir before /usr/bin. You can do something like this:

export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH

And should looks like the following after the changes:

/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:
/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:
/Users/masi/.cabal/bin

After that, you must be able to use stdbuf.


coreutils on OS X adds the prefix g to all the commands so as to not mess up with default programs on OS X.

It prints this when you run brew install coreutils

==> Caveats
All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

So unless you really need to use it as stdbuf, there is no real reason to update your path, you can simply run gstdbuf instead:

$ gstdbuf --help                                                         
Usage: gstdbuf OPTION... COMMAND 

If you don't want to mess with your PATH and all you need is stdbuf:

cd /usr/local/bin
sudo ln -s ../opt/coreutils/libexec/gnubin/stdbuf stdbuf

For whatever reason I also already had coreutils brewed, but only certain binaries linked - not remembering why, this seemed like the safest option