Is it possible to get, using Bash, a list of commands starting with a certain string?
I would like to get what is printed hitting <tab> twice after typing the start of the command and, for example, store it inside a variable.
Is it possible to get, using Bash, a list of commands starting with a
Share
You should be able to use the compgen command, like so:
For example, ‘compgen -A builtin l’ returns
You can use other keywords in place of ‘builtin’ to get other types of completion. Builtin gives you shell builtin commands. ‘File’ gives you local filenames, etc.
Here’s a list of actions (from the BASH man page for complete which uses compgen):