I was discussing with my friend on how the commands are parsed in the shell, and he told me that bash searches the command in following order

  1. List of aliases
  2. List of shell keywords
  3. List of user defined functions
  4. List of shell built in functions
  5. List of directories specified in the PATH variable , from left to right.

I know aliases can be found by issuing the "alias" command. PATH variable contents can be found using "echo $PATH" command.

Can you please tell me which commands do I need to use to

  1. list all shell keywords
  2. list all user defined functions
  3. list all shell built in functions



list all shell keywords

Consult your shell's manual for that. "Keyword" is a little ambiguous—for Bash, see the defined builtins below, or consider looking at the shell variables, special parameters, or the index of shell reserved words.

list all user defined functions

In Bash (and Zsh, and probably others), you can use typeset -f to list all functions.

list all shell built in functions

The Bash Reference Manual gives you a list of:

In OS X you can also check out the manpage at man builtin for a comparison between builtins available in different shells. I'm not sure if this is available in GNU/Linux.

  • +1.Thanks for elaboration. I checked and man builtins worked in GNU/Linux/. Also from other post I found that man bash | grep -10 RESERVED and enable are useful for reserved words and builtins respectively. – Forever Learner Feb 1 '13 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.