Using a function in bash allows you to create something in Linux that works as if it were a script within a script. Whenever the data being processed matches a set of conditions, your script can call a function that does further processing.
The format of a function is very straightforward. The syntax looks like this:
<function_name> () {
<commands>
}
You can also use the following format that uses the word “function” if you prefer:
function <function_name> {
<commands>
}
In fact, you can also create a function on a single line if the commands to be run are limited, but note the required “;” that follows the command(s):
To read this article in full, please click here
Source:: Network World – Linux