Functions simplify code and enable scripting code reuse. One definition can be invoked more than once. Structured programming to enhance readability, you can define functionality as multiple functions, then save it in a file, and then use Source (.) in ~/BASHRC or at the command line. Call this file. Speed up the operation
1. Methods of defining functions (traditional style)
function name{
}
C Language Style:
Name () {
}
It is recommended to use C language style, good compatibility, can be used in Csh/tsch
The difference between return and exit in a function, returning exits execution, returns to the main program function, and continues execution
Exit exits the current script directly.
The role of shift in the shell, like assigning a $ to $1,$3 assignment to $2,$4 to $
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/