2

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?

  • 1
    Use the `-M` option to specify the directories to search for man pages. – Barmar Mar 11 '20 at 17:13
  • Have you set the MANPATH environment variable? If so, unsetting it would probably do the job. Reading `man man` shows that there are a *lot* of configuration options. – Jonathan Leffler Mar 11 '20 at 17:25
  • That's why some folk install the **homebrew** stuff as `gstat`, `gfind`, `gdate` – Mark Setchell Mar 11 '20 at 18:05
  • StackOverflow is dedicated to helping solve programming code problems. Your Q **may be** more appropriate for [apple.se] or [su] , but read their help section regarding on-topic questions . AND please read [Help On-topic](https://stackoverflow.com/Help/On-topic) and [Help How-to-ask](https://stackoverflow.com/Help/How-to-ask) before posting more Qs here. Good luck. – shellter Mar 11 '20 at 19:29

2 Answers2

1

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
chepner
  • 497,756
  • 71
  • 530
  • 681
0

In order to retrieve a man page it must be found in the manpath. The directories that are listed by the manpath are set by /etc/manpath.config. This can be overwritten via an environment variable $MANPATH. If the man page you are looking for is in this path already, then you should see a listing like the following:

stat (1)
stat (2)
stat (3p)
stat (3p+2)

That (3p+2) represents a duplicated entry. Since you believe you have two different man pages, you should see something like this. If not, then the man page you want either does not exist on your system, or is outside of the manpath. You can specify a custom manpath with the -M option. This will override the $MANPATH variable. From the man man:

-M path, --manpath=path
       Specify an alternate manpath to use.  By default, man uses manpath derived code to determine the path to search.  This option overrides the $MANPATH environment variable and causes option -m to be ignored.

       A path specified as a manpath must be the root of a manual page hierarchy structured into sections as described in the man-db manual (under "The manual page system").  To view manual pages outside such hierarchies, see the -l option.
Jason
  • 2,493
  • 2
  • 27
  • 27
  • Where should I see this listing? Also it seems that on macOX (catalina at least), the configuration is located under /etc/man.conf – Jonathan Daigle Mar 11 '20 at 18:09