Anchor(faq84)

How do I return a string from a function? "return" only lets me give a number.

Functions in Bash (as well as all the other Bourne-family shells) work like commands; that is, they only "return" an exit status, which is a number from 0 to 255 inclusive. This is intended to be used only for signaling errors, not for returning the results of computations, or other data.

If you need to send back arbitrary data from a function to its caller, there are at least three methods by which this can be achieved: