

We may also create a variable as a local variable. This means that it is visible everywhere in the script. Scope refers to which parts of a script can see which variables. Sometimes that is ok because that is what you want. Just be wary if you take this approach as if you don't call the function with command substitution then it will print the result to the screen.

Think of a function as a small script within a script. In this section of our Bash scripting tutorial you'll learn how they work and what you can do with them. Functions in Bash Scripting are a great way to reuse code.
