Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

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.*) '
share|improve this answer

You can use the type command to do this.

type yourfunc will print the function to STDOUT. As man type says,

The type utility shall indicate how each argument would be interpreted if used as a command name.
share|improve this answer
man type? Shell builtins usually have no man page on my system. – manatwork Dec 27 '12 at 8:41
I have updated my answer with a link. The system I use is Arch Linux. – jasonwryan Dec 27 '12 at 8:55
Thank you. Seems the man-pages package contains much more on Arch. – manatwork Dec 27 '12 at 9:05
No problem: as it is one of the POSIX man pages, I thought it would be widely distributed... – jasonwryan Dec 27 '12 at 9:10
help type shows the Bash-specific information. – l0b0 Dec 27 '12 at 12:25

for builtin commands' info use:

help [-s|-d] COMMAND1 COMMAND2 ....

for example:

help help alias

For info about all of them type, for example:

help -s '' 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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