如何打印 unix 命令行工具的所有可能命令



我想查看特定命令行工具的所有可能选项的列表。--help选项可能很有用,但可能不包括所有选项,有时您只需要一个列表而不是详细说明。基本上相当于 python 中的 dir() bash。

例如:

该命令python --help提取选项/参数的描述。但是,它不包括诸如 python --version .bash有办法检查这一点吗?

这取决于您要获取帮助的内容。

对于像 python 这样的可执行文件,最好的选择是手册页。不过,这仅在Unix上真正可用。例如。

man python

这将打开一个如下所示的屏幕:

PYTHON(1)                   General Commands Manual                  PYTHON(1)
NAME
       python  - an interpreted, interactive, object-oriented programming lan‐
       guage
SYNOPSIS
       python [ -B ] [ -d ] [ -E ] [ -h ] [ -i ] [ -m module-name ]
              [ -O ] [ -OO ] [ -R ] [ -Q argument ] [ -s ] [ -S ] [ -t ] [ -u ]
              [ -v ] [ -V ] [ -W argument ] [ -x ] [ -3 ] [ -?  ]
              [ -c command | script | - ] [ arguments ]
DESCRIPTION
       Python is an interpreted, interactive, object-oriented programming lan‐
       guage that ...
COMMAND LINE OPTIONS
       ...
       -V ,  --version
              Prints the Python version number of the executable and exits.
       ...

这使用名为 less 的程序来显示信息。您可以使用箭头键滚动并使用 q 退出。在更少的命令中有更多的可用命令。键入 man less 以了解更多信息。

如果您正在寻求内置 bash 的帮助(例如。 echo ) 尝试内置的 bash help例如。

help echo

相关内容

最新更新