Functions: Naming rules are the same as variables
Executing functions in the current shell process
Modularity of the program for easy maintenance
Basic function Syntax:
function function name () { Command Area } #注: The # function name can be directly connected to the following parentheses or separated by a space # keyword function and () One of the two can be omitted # before function calls need to be defined beforehand # The return value of the last command in the function represents the end state of the function # Execution encounters return immediate End Function call, and return value 0 # command area use Return n (0~255) can specify a return value # The function is valid only in a defined shell environment # when a parameter is passed to a function, the function name is separated by a space between the arguments # variables defined in script are global variables relative to script, affecting their inner function area # use positional parameters $n to pass variable values instead of using variables # Use the local variable name = variable value in a function to make the variable internal, without affecting the variable with the same name outside the function
^_^
This article is from the "junight" blog, make sure to keep this source http://junight.blog.51cto.com/10828785/1729866
[Note]shell Basics of function usage