Bash – Display the function body in Bash

bashfunction

I have setup several functions in my .bashrc file. I would like to just display the actual code of the function and not execute it, to quickly refer to something.

Is there any way, we could see the function definition?

Best Answer

The declare builtin's -f option does that:

bash-4.2$ declare -f apropos1
apropos1 () 
{ 
    apropos "$@" | grep ' (1.*) '
}

I use type for that purpose, it is shorter to type ;)

bash-4.2$ type apropos1
apropos1 is a function
apropos1 () 
{ 
    apropos "$@" | grep ' (1.*) '
}