LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Error Executing function. (https://www.linuxquestions.org/questions/linux-newbie-8/error-executing-function-818884/)

pinga123 07-09-2010 05:50 AM

Error Executing function.
 
Hi ,

I have written following code but its giving me two warning after execution.
What went wrong here?

Code:

function1()
{
echo "Hi"
}
function2()
{
echo $1
}
function3
{
echo "TATA"
}
function1
function2 "bye"
function3

Output

Code:

./sample.sh: line 9: function3: command not found
TATA
Hi
bye
./sample.sh: line 15: function3: command not found

Everything seems to be fine but why m i getting command not found.

pinga123 07-09-2010 05:52 AM

I m sorry . I got my mistake .

Guttorm 07-09-2010 05:53 AM

To make a function in shell, you should do it like this

function function1
{
echo "..."
}

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html

pinga123 07-09-2010 11:57 PM

Quote:

Originally Posted by Guttorm (Post 4028175)
To make a function in shell, you should do it like this

function function1
{
echo "..."
}

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html

the same thing can be written as
function1()
{
echo ".."
}


All times are GMT -5. The time now is 11:02 AM.