compgen

From RaySoft

Generate possible completion matches for word according to the options.[1]

Documentation

Syntax

compgen [PARAMETER ...] FILTER

Parameters

-A ACTION
The ACTION may be one of the following to generate a list of possible completions:
alias
Alias names. May also be specified as -a.
builtin
Names of shell builtin commands. May also be specified as -b.
command
Command names. May also be specified as -c.
export
Names of exported shell variables. May also be specified as -e.
function
Names of shell functions.
variable
Names of all shell variables. May also be specified as -v.

Examples

List all commands starting with 'ls'
compgen -A 'command' 'ls'

Output:

lscpu
lsattr
lslocks
...

References

  1. man 1 'bash'