在macOS中,当我安装了GNU替代方案时,如何获得原始(BSD)命令的手动(man)页面



所以我安装了GNU核心实用程序,如下所示:brew install coreutils现在我有两个版本的核心实用程序。

例如:

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

/usr/local/opt/coreutils/libexec/gnubin/stat是如果我简单地调用stat将执行的GNU版本,如果我调用man stat,我将获得该特定版本的手册。

现在我的问题是如何查看/usr/bin/stat版本的手册?

使用man -wa列出所有路径,然后使用所需的特定手册页作为man的参数。

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

假设您已经知道您想要的页面在/usr/share/man中(或者已经通过运行上一个命令了解到这一点(,则可以使用-M选项来覆盖man的常规搜索。

$ man -M /usr/share/man stat

要检索手册页,必须在manpath中找到该手册页。由manpath列出的目录由/etc/manpath.config设置。这可以通过环境变量$MANPATH来重写。如果你正在寻找的手册页已经在这个路径上了,那么你应该会看到如下列表:

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

那个(3p+2(表示一个重复的条目。既然你相信你有两个不同的手册页,你应该看到这样的东西。如果没有,那么您想要的手册页在您的系统中不存在,或者在手册路径之外。可以使用-M选项指定自定义manpath。这将覆盖$MANPATH变量。来自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.

最新更新