brew install gnu-stat

The stat command on Ubuntu and OS X behave differently and I’d like to have the functionality of the GNU / Ubuntu version of stat available on OS X – if there is such a thing. I have already used homebrew to install gnu-sed and I see similarly that a lot of the GNU utilities are available from:

brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt

I know stat on OS X might be very specialized because of the OS X file systems that may be present, but I’d ALSO like to have the linuxy version if it is available. As it turns out, it is.

The GNU version of stat can be accessed on OS X by installing a package / keg called coreutils which includes the following utilities:

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

These GNU utilities are available on Mac OS X but the one caveat is that they are all prefixed by the letter g as you can see from brew info:

$ brew info coreutils
coreutils: stable 8.21
Depends on: xz
/usr/local/Cellar/coreutils/8.21 (210 files, 9.6M) *
  Built from source
==> 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:


Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:


The utilities with the g prefix are named:

g[         gecho      gmkfifo    grmdir     gtimeout
gbase64    genv       gmknod     gruncon    gtouch
gbasename  gexpand    gmktemp    gseq       gtr
gcat       gexpr      gmv        gsha1sum   gtrue
gchcon     gfactor    gnice      gsha224sum gtruncate
gchgrp     gfalse     gnl        gsha256sum gtsort
gchmod     gfmt       gnohup     gsha384sum gtty
gchown     gfold      gnproc     gsha512sum guname
gchroot    ggroups    gnumfmt    gshred     gunexpand
gcksum     ghead      god        gshuf      guniq
gcomm      ghostid    gpaste     gsleep     gunlink
gcp        gid        gpathchk   gsort      guptime
gcsplit    ginstall   gpinky     gsplit     gusers
gcut       gjoin      gpr        gstat      gvdir
gdate      gkill      gprintenv  gstty      gwc
gdd        glink      gprintf    gsum       gwho
gdf        gln        gptx       gsync      gwhoami
gdir       glogname   gpwd       gtac       gyes
gdircolors gls        greadlink  gtail
gdirname   gmd5sum    grealpath  gtee
gdu        gmkdir     grm        gtest

Related Posts:

  • No Related Posts
This entry was posted in Mac, Server Admin, Tech Tips and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *