Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list the functions defined in my shell? [duplicate]

People also ask

How do I list functions in bash?

Function names and definitions may be listed with the -f option to the declare builtin command (see Bash Builtins). The -F option to declare will list the function names only (and optionally the source file and line number).

Where are shell functions stored?

Shell functions are stored in the memory of the shell (or, perhaps, in undocumented temporary files). They don't exist in any usable way until the shell starts (e.g., when you login to a CLI, or start a shell window such as xterm ) and they are defined (e.g., by reading . bashrc , .

What is the shell command to list all the commands?

ls. The 'ls' command lists the contents of either the current directory or the directories listed on the command line. For files listed on the command line, it just lists them. Multiple directories may be listed, in which case each directory is shows one by one.

Where are functions stored bash?

Basically bash functions are permanently stored in a bash start-up script. System-wide start-up scripts: /etc/profile for login shells, and /etc/bashrc for interactive shells.


declare -F

Function names and definitions may be listed with the -f option to the declare builtin command (see Bash Builtins). The -F option to declare will list the function names only (and optionally the source file and line number).

Bash Reference Manual


Assuming bash shell:

typeset -f

will list the functions.

typeset -F

will list just the function names.


declare -F

will give you the names of all functions

type function_name

will give you the source for a particular function


declare -F actually prints declare commands and not only function names:

$ declare -F
declare -f function1
declare -f function2

You can use compgen -A function to print only function names:

$ compgen -A function
function1
function2