Skip to content

Instantly share code, notes, and snippets.

@evanrrees
Forked from skyzyx/homebrew-gnubin.md
Last active April 10, 2024 18:16
Show Gist options
  • Select an option

  • Save evanrrees/ee9124a8f519677c6dc94ca941d2fb1c to your computer and use it in GitHub Desktop.

Select an option

Save evanrrees/ee9124a8f519677c6dc94ca941d2fb1c to your computer and use it in GitHub Desktop.

Revisions

  1. evanrrees revised this gist Jun 2, 2021. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -18,13 +18,12 @@ brew install autoconf bash binutils coreutils diffutils ed findutils flex gawk \
    screen watch wdiff wget
    ```

    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to your `~/.profile` file.
    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to `~/.bash_profile`.

    ```bash
    # Get list of gnubin directories
    export GNUBINS="$(find /usr/local/opt -type d -follow -name gnubin -print)";

    for bindir in ${GNUBINS[@]}; do
    export PATH=$bindir:$PATH;
    done;
    if type brew &>/dev/null; then
    HOMEBREW_PREFIX=$(brew --prefix)
    for d in ${HOMEBREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$d:$PATH; done
    for d in ${HOMEBREW_PREFIX}/opt/*/libexec/gnuman; do export MANPATH=$d:$MANPATH; done
    fi
    ```
  2. @skyzyx skyzyx revised this gist May 10, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,9 @@ I think most of us realize that macOS isn't a Linux OS, but what that also means
    You can install most of the GNU flavored tools with:

    ```bash
    brew install autoconf bash binutils coreutils diffutils ed findutils flex gawk gnu-indent gnu-sed gnu-tar gnu-which gpatch grep gzip less m4 make nano screen watch wdiff wget
    brew install autoconf bash binutils coreutils diffutils ed findutils flex gawk \
    gnu-indent gnu-sed gnu-tar gnu-which gpatch grep gzip less m4 make nano \
    screen watch wdiff wget
    ```

    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to your `~/.profile` file.
  3. @skyzyx skyzyx revised this gist May 10, 2020. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -13,15 +13,16 @@ I think most of us realize that macOS isn't a Linux OS, but what that also means
    You can install most of the GNU flavored tools with:

    ```bash
    brew install coreutils ed findutils gawk gnu-sed gnu-tar grep make
    brew install autoconf bash binutils coreutils diffutils ed findutils flex gawk gnu-indent gnu-sed gnu-tar gnu-which gpatch grep gzip less m4 make nano screen watch wdiff wget
    ```

    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to your `~/.profile` file.

    ```bash
    if type brew &>/dev/null; then
    export BREW_PREFIX="$(brew --prefix)"
    for bindir in ${BREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$bindir:$PATH; done
    for mandir in ${BREW_PREFIX}/opt/*/libexec/gnuman; do export MANPATH=$mandir:$MANPATH; done
    fi
    # Get list of gnubin directories
    export GNUBINS="$(find /usr/local/opt -type d -follow -name gnubin -print)";

    for bindir in ${GNUBINS[@]}; do
    export PATH=$bindir:$PATH;
    done;
    ```
  4. @skyzyx skyzyx revised this gist May 10, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -20,8 +20,8 @@ Assuming you have a fairly standard Terminal/shell environment, and assuming tha

    ```bash
    if type brew &>/dev/null; then
    export BREW_PREFIX="$(brew --prefix)"
    for bindir in ${BREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$bindir:$PATH; done
    for mandir in ${BREW_PREFIX}/opt/*/libexec/gnuman; do export MANPATH=$mandir:$MANPATH; done
    export BREW_PREFIX="$(brew --prefix)"
    for bindir in ${BREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$bindir:$PATH; done
    for mandir in ${BREW_PREFIX}/opt/*/libexec/gnuman; do export MANPATH=$mandir:$MANPATH; done
    fi
    ```
  5. @skyzyx skyzyx revised this gist May 10, 2020. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -19,10 +19,9 @@ brew install coreutils ed findutils gawk gnu-sed gnu-tar grep make
    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to your `~/.profile` file.

    ```bash
    # Get list of gnubin directories
    export GNUBINS="$(find /usr/local/opt -type d -follow -name gnubin -print)";

    for bindir in ${GNUBINS[@]}; do
    export PATH=$bindir:$PATH;
    done;
    if type brew &>/dev/null; then
    export BREW_PREFIX="$(brew --prefix)"
    for bindir in ${BREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$bindir:$PATH; done
    for mandir in ${BREW_PREFIX}/opt/*/libexec/gnuman; do export MANPATH=$mandir:$MANPATH; done
    fi
    ```
  6. @skyzyx skyzyx revised this gist Apr 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ I think most of us realize that macOS isn't a Linux OS, but what that also means

    > All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.
    ## Choosing GNU
    ## Choosing GNU for Consistency

    You can install most of the GNU flavored tools with:

  7. @skyzyx skyzyx revised this gist Apr 19, 2019. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions provides.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    ## `coreutils` provides:

    `[`, `b2sum`, `base32`, `base64`, `basename`, `basenc`, `cat`, `chcon`, `chgrp`, `chmod`, `chown`, `chroot`, `cksum`, `comm`, `cp`, `csplit`, `cut`, `date`, `dd`, `df`, `dir`, `dircolors`, `dirname`, `du`, `echo`, `env`, `expand`, `expr`, `factor`, `false`, `fmt`, `fold`, `groups`, `head`, `hostid`, `id`, `install`, `join`, `kill`, `link`, `ln`, `logname`, `ls`, `md5sum`, `mkdir`, `mkfifo`, `mknod`, `mktemp`, `mv`, `nice`, `nl`, `nohup`, `nproc`, `numfmt`, `od`, `paste`, `pathchk`, `pinky`, `pr`, `printenv`, `printf`, `ptx`, `pwd`, `readlink`, `realpath`, `rm`, `rmdir`, `runcon`, `seq`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`, `shred`, `shuf`, `sleep`, `sort`, `split`, `stat`, `stdbuf`, `stty`, `sum`, `sync`, `tac`, `tail`, `tee`, `test`, `timeout`, `touch`, `tr`, `true`, `truncate`, `tsort`, `tty`, `uname`, `unexpand`, `uniq`, `unlink`, `uptime`, `users`, `vdir`, `wc`, `who`, `whoami`, `yes`

    ## `ed` provides:

    `ed`, `red`

    ## `gawk` provides:

    `awk`

    ## `grep` provides:

    `egrep`, `fgrep`, `grep`

    ## `gnu-sed` provides:

    `sed`

    ## `gnu-tar` provides:

    `tar`

    ## `make` provides:

    `make`

    ## `findutils` provides:

    `find`, `locate`, `updatedb`, `xargs`
  8. @skyzyx skyzyx revised this gist Apr 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ Assuming you have a fairly standard Terminal/shell environment, and assuming tha

    ```bash
    # Get list of gnubin directories
    export GNUBINS="$(find /usr/local/opt -xtype d -follow -name gnubin -print)";
    export GNUBINS="$(find /usr/local/opt -type d -follow -name gnubin -print)";

    for bindir in ${GNUBINS[@]}; do
    export PATH=$bindir:$PATH;
  9. @skyzyx skyzyx created this gist Apr 19, 2019.
    28 changes: 28 additions & 0 deletions homebrew-gnubin.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    **macOS** is a Unix, and not built on Linux.

    I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.

    ## Homebrew

    [Homebrew](https://brew.sh) can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

    > All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.
    ## Choosing GNU

    You can install most of the GNU flavored tools with:

    ```bash
    brew install coreutils ed findutils gawk gnu-sed gnu-tar grep make
    ```

    Assuming you have a fairly standard Terminal/shell environment, and assuming that you want to use the GNU versions instead of the BSD versions for everything you've installed with Homebrew, you can append the following to your `~/.profile` file.

    ```bash
    # Get list of gnubin directories
    export GNUBINS="$(find /usr/local/opt -xtype d -follow -name gnubin -print)";

    for bindir in ${GNUBINS[@]}; do
    export PATH=$bindir:$PATH;
    done;
    ```