Hi,
As I came from other programming languages, I had written this small code for learning purpose:
#!/bin/sh
function greet()
{
msg=$1
echo In function Greet
echo Hello $msg
}
ret=$(greet ' World')
echo $ret
echo In Main Program
echo $ret
In the above code, When I run .... it gives me the output:
In function Greet Hello World
In Main Program
In function Greet Hello World
But actually, I want only "Hello World" in the $ret variable. As I know that if you want to return some data from the function you have to write echo statement.
Here there are 2 echo statements in function, one merely prints a just a simple statement and one do some processing.
Then how to get only "Hello World" in ret variable?
Help !!