First page Back Continue Last page Graphics
Functions
Function scope is from the point the function is defined to the end of the file (that is, it must be defined before you can use it). Generally, that means that all functions precede the main body of the script.
As a result, previously-written functions are often included in a script using the source (also . (dot)) statement near the top of a script.
You can define local variables to be used only inside the function, while your normal variables from outside the function can always be used.
If you wish, you can pass arguments into a function as positional parameters ($1 and so on; this is by far the recommended approach).