如何打印 unix 命令行工具的所有可能命令?
How can you print all the possible commands of a unix command line tool?
我想查看特定命令行工具的所有可能选项的列表。 --help
选项可能很有用,但可能不包括所有选项,有时您只需要一个列表而不是详细描述。基本上 bash 相当于 python.
中的 dir()
例如:
命令 python --help
提取 options/arguments 的描述。但是它不包括 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 退出。在 less 中有更多可用的命令。输入 man less
以了解更多信息。
如果您正在寻找有关 bash 内置(例如 echo
)的帮助,请尝试 bash 内置 help
例如。
help echo
我想查看特定命令行工具的所有可能选项的列表。 --help
选项可能很有用,但可能不包括所有选项,有时您只需要一个列表而不是详细描述。基本上 bash 相当于 python.
dir()
例如:
命令 python --help
提取 options/arguments 的描述。但是它不包括 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 退出。在 less 中有更多可用的命令。输入 man less
以了解更多信息。
如果您正在寻找有关 bash 内置(例如 echo
)的帮助,请尝试 bash 内置 help
例如。
help echo