Linux命令列出所有可用的命令和别名 [英] Linux command to list all available commands and aliases

查看:209
本文介绍了Linux命令列出所有可用的命令和别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个Linux命令将列出此终端会话的所有可用命令和别名?

Is there a Linux command that will list all available commands and aliases for this terminal session?

如果您输入a并按下选项卡,字母表的字母。
或运行别名,但也返回命令。

As if you typed 'a' and pressed tab, but for every letter of the alphabet. Or running 'alias' but also returning commands.

为什么?我想运行以下命令并查看命令是否可用:

Why? I'd like to run the following and see if a command is available:

ListAllCommands | grep searchstr


推荐答案

可以使用bash -in compgen

You can use the bash(1) built-in compgen


  • compgen -c 将列出您可以运行的所有命令。

  • compgen -a 将列出您可以运行的所有别名。 / li>
  • compgen -b 将列出您可以运行的所有内置程序。

  • <$

  • compgen -A函数将列出您可以运行的所有函数。

  • compgen -A函数-abck 将一次列出所有上述内容。 / li>
  • compgen -c will list all the commands you could run.
  • compgen -a will list all the aliases you could run.
  • compgen -b will list all the built-ins you could run.
  • compgen -k will list all the keywords you could run.
  • compgen -A function will list all the functions you could run.
  • compgen -A function -abck will list all the above in one go.

检查您可以生成的其他完成的手册页。

Check the man page for other completions you can generate.

回答您的问题:

compgen -ac | grep searchstr

应该做什么你想要的。

这篇关于Linux命令列出所有可用的命令和别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆