How to create & use functions in shell scripts. How to pass parameters to a function and use it, using return values.
Many times it becomes necessary to pass arguments in functions. These arguments can be taken from the user during runtime or can be passed on via environment variables etc.
Syntax -
$ function_name $arg1 $arg2
Example -
mytestfunc()
{
c = $1+$2
}
To return values within function.
function_name()
{
echo “testing return”
return 1
}