Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I can define and print the contents of variable called my_var like this:

my_var="hello"
echo $my_var

but if I define:

my_funct {echo "hello";}

how can I recall my function's definition later on?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

With the type command:

dennis@lightning:~$ foo() { echo "hi"; }
dennis@lightning:~$ type foo
foo is a function
foo () 
{ 
    echo "hi"
}
share|improve this answer
    
Great!, thanks! –  Robert Vila Nov 16 '12 at 19:05

To get just the definition without "foo is a function",

$ declare -f foo
foo () 
{ 
    echo "hi"
}
share|improve this answer

Your Answer

 
discard

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.