How do I list the functions defined in my shell? [duplicate]
I can type alias to show a list of all the aliases.
But for functions, all I can do is grep my .bash_profile
.
That only gets the ones in that file, not those defined in subsidiary files or dynamically.
Is there a more convenient way to find out what functions are currently defined?
Solution 1:
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
Solution 2:
Assuming bash shell:
typeset -f
will list the functions.
typeset -F
will list just the function names.
Solution 3:
declare -F
will give you the names of all functions
type function_name
will give you the source for a particular function
Solution 4:
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