What are commands to find shell keywords, built in functions and user defined functions?

You can also use compgen in bash:

  • compgen -k lists keywords
  • compgen -b or enable lists builtins
  • compgen -A function or declare -F lists functions
  • compgen -a or alias lists aliases
  • compgen -c lists commands
  • compgen -v lists variables
  • compgen -e or export lists exported variables

With zsh:

PATH= type -m '*'

Will tell you all 3.

In bash, to list the keywords, you can do:

complete -A keyword :

and then type : <Tab><Tab>

For builtins, replace keyword with builtin above and for functions, I'll let you guess.


In Bash:

  1. man bash | grep -10 RESERVED lists reserved words:

    ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
  2. declare -F and typeset -F shows function names without their contents.

  3. enable lists builtin shell commands (I don't think these are functions as such).So does man builtins