Tuesday, June 14, 2011

Functions in Bash

#/usr/bin/bash

function myfunc()
{
myresult='some value'
}

# Call it with arguments and $1 will be the first argument.
function somefunc ()
{
echo "called function with argument $1"
}

myfunc

# functions that takes arguments
somefunc Sam
somefunc Ram

echo $myresult

exit 0

No comments:

Post a Comment