如何获得所有可用的Shell命令的列表
问题描述:
在典型的Linux shell(bash)中,可以两次单击tab键,以获得所有可用的shell命令的列表.
In a typical Linux shell (bash) it is possible to to hit tab twice, to get a list of all available shell commands.
是否存在具有相同行为的命令?我想将其传送到 grep
并进行搜索.
Is there a command which has the same behaviour? I want to pipe it into grep
and search it.
答
您可以使用compgen.例如:
You could use compgen. For example:
compgen -c
您也可以像这样对它进行grep:
You also could grep it, like this:
compgen -c | grep top$
来源: http://www.cyberciti.biz/open-source/command-line-hacks/compgen-linux-command/