Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RETURN variable

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
Is there a method to return a variable when a function is called? something like the following?

functionA()
{
(( a=100 + $1 ))

return a

}


tmp_a=`functionA 100`

-------------------------------------------
I'd like to store the returned "200" value into "tmp_a".

Thanks for any advice...

je
 
functionA()
{
(( a=100 + $1 ))

echo $a

}


tmp_a=`functionA 100`
 
Or just create a global variable.
Code:
function add() {
num=$1
add=$2
    num=`eval expr $num + $add`
export num
}

add 12 34 ; echo $num
46
add 32 31 ; echo $num
63

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top