compgen is bash built-in command and it will show all available commands, aliases, and functions.
and it is used to get the specific set of words from a word list ( ?? )
To list all the commands available :
$ compgen -c alert c d egrep fgrep .. .. .. bzexe espdiff sol gnome-mines gnome-sudoku
To list all the bash shell aliases available :
$ compgen -a alert c d egrep fgrep grep l la
To list all the bash build-ins :
$ compgen -b . : [ alias bg bind break builtin caller cd
To list all the bash keywords :
$ compgen -k if then else elif fi case esac for select while until do done in function time { } ! [[ ]] coproc
To list all the bash functions :
dinesh@ubuntu:~$ compgen -A function __colormgrcomp __expand_tilde_by_ref __get_cword_at_cursor_by_ref __grub_dir __grub_get_last_option .. .. _zeitgeist_daemon command_not_found_handle dequote quote quote_readline
-A (action) is very useful option. The action may be one of the following to generate list of possible completions.
alias, arrayvar, binding, builtin, command, directory, enabled, disabled, export, file, function, group, hostname, job, keyword, running, service, setopt, signal, user, variable.
To get word[s] from word-list :
dinesh@ubuntu:$ compgen -W "aa ab ac ba bb" aa ab ac ba bb dinesh@ubuntu:$ compgen -W "aa ab ac ba bb" -- b ba bb
0 comments:
Post a Comment