Returning string values from a bash function

Cameron Hutchison lists at xdna.net
Sun Nov 22 06:48:13 UTC 2009


Ray Parrish <crp at cmc.net> writes:

>I need to know how to return a string value from a bash function. I 
>tried using "return $VariableName", and got the error that return 
>expected a numeric value.

You use "echo".

eg.

foo()
{
  echo "result"
}

bar=$(foo)





More information about the ubuntu-users mailing list