Search code examples
bashmacosmanpage

In macOS, how can I get the manual (man) page of the original (BSD) command when I have installed a GNU alternative?


So I have installed GNU coreutils like so : brew install coreutils Now I have 2 versions of my core utilities.

For example :

$>which -a stat
/usr/local/opt/coreutils/libexec/gnubin/stat
/usr/bin/stat

/usr/local/opt/coreutils/libexec/gnubin/stat is the GNU version that will be executed if I simply invoke stat And if I invoke man stat I will get the manual for that specific version.

Now my question is how can I look at the manual for the /usr/bin/stat version?


Solution

  • Use man -wa to list all paths, then use the specific man page you want as the argument to man.

    $ man -wa stat
    /usr/share/man/man1/stat.1
    [some Xcode cruft deleted]
    $ man /usr/share/man/man1/stat.1
    

    Assuming you already knew that the page you wanted was in /usr/share/man, (or having learned that by running the previous command), you can use the -M option to override man's usual search.

    $ man -M /usr/share/man stat