Answers:
您可以利用内建函数compgen
:
compgen: compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat]
[-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix]
[-S suffix] [word]
Display possible completions depending on the options.
Intended to be used from within a shell function generating possible
completions. If the optional WORD argument is supplied, matches against
WORD are generated.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.
TAB在提示符下将列出命令,shell内置函数,关键字,别名和函数。所以你可以说:
compgen -cbka -A function | grep '^y' > myfile.txt
以获取yTAB在shell提示符下键入文件时看到的所有选项myfile.txt
。
消除grep
管道,以便将所有可能的命令,函数,...放入文件中:
compgen -cbka -A function > myfile.txt
y
:: 开头。这与您在问题中所显示的非常一致!
compgen -cbka -A function > myfile.txt
抓取完整的输出。谢谢!我(显然)从来不知道这个新的有趣功能。