The code shell used many times as a function of a combination of a set up, easy to use n times, reducing the amount of code, so convenient, clean.
When the need to modify the inside of duplicate code, if you combined into a function, you only need to modify the function can be realized once demand; the function can also be written into the file, when you need to call in the script is loaded into use.
function: Functions
function_name: function name
return n: Return Value n: number - similar role exit n
Function Syntax 1: function function_name () {spaces Set of instructions return n } |
2 function syntax: function function_name spaces { Set of instructions return n } |
3 function syntax: FUNCTION_NAME () {spaces Set of instructions return n } |
How to perform a function:
If no parameters, then directly enter the function name, with nothing.
What function Note:
1. Before using the function, you need to define or load, if the load function, you need a source or point to load.
2. When the function is executed, the script would call it and use variables together, of course, can in set up a local variable or function in a special position variable, generally use local define local variables, the equivalent sub-shell, local variables expire at the exit function
3. make good use of function, good habits