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).
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 , .
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.
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 thedeclare
builtin command (see Bash Builtins). The-F
option todeclare
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With