在 macOS 中,当我安装了 GNU 替代品时,如何获取原始 (BSD) 命令的手册页?
In macOS, how can I get the manual (man) page of the original (BSD) command when I have installed a GNU alternative?
所以我像这样安装了 GNU coreutils:brew install coreutils
现在我有 2 个版本的核心实用程序。
例如:
$>which -a stat
/usr/local/opt/coreutils/libexec/gnubin/stat
/usr/bin/stat
/usr/local/opt/coreutils/libexec/gnubin/stat 是 GNU 版本,如果我简单地调用 stat
将执行,如果我调用 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.
所以我像这样安装了 GNU coreutils:brew install coreutils
现在我有 2 个版本的核心实用程序。
例如:
$>which -a stat
/usr/local/opt/coreutils/libexec/gnubin/stat
/usr/bin/stat
/usr/local/opt/coreutils/libexec/gnubin/stat 是 GNU 版本,如果我简单地调用 stat
将执行,如果我调用 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.