As with other programming languages, shell programs also support functions. A function is a piece of a shell program that performs a particular process; you can reuse the same function multiple times within the shell program. Functions help eliminate the need for duplicating code as you write shell programs.
The following is the format of a function in
You can call a function as follows:
func param1 param2 param3
param2, and so on are optional. You can also pass the parameters as a single string—for example,
$@. A function can parse the parameters as if they were positional parameters passed to a shell program from the command line as command-line arguments, ...