Upgrade Bash to 4+ on OS X and Use GNU Instead of BSD Command

Install latest bash

Install by brew for OS X user brew install bash

Compiling bash with source code: http://ftp.gnu.org/gnu/bash/

  • Add /usr/local/bin/bash to /etc/shells
  • Change the default shell with chsh -s /usr/local/bin/bash
  • To see your current version of bash do the following: echo $BASH_VERSION

Install and Use GNU Command Line Tools on Mac OS X

If you are moving onto Mac OS X from Linux, you would probably find out that the command line tools shipped with Mac OS X are not as powerful and easy to use as the tools in Linux. The reason is that Mac OS X uses the BSD version command line tools, which are different from the Linux version, while they are both compliant with POSIX standards.

  • Install the GNU Command Line Tools

    Get the latest GNU Coreutils and install to /usr/local/coreutils/

    wget http://ftpmirror.gnu.org/coreutils/coreutils-8.22.tar.xz
    tar xzf coreutils-8.22.tar.xz && cd coreutils-8.22
    ./configure --prefix=/usr/local/coreutils-8.22
    sudo make install
    sudo ln -sf /usr/local/coreutils-8.22 /usr/local/coreutils
  • Enable GNU coreutils, add coreutils bin folder to $PATH

    add script to .profile or .bash_profile

    export PATH="/usr/local/coreutils/bin:$PATH"