1. variable order
In the script, there is no global or local variable for the same process.
It is just a break. If you use a variable in a function, and there is no trace of this variable outside the function. However, as long as you have called this function, you can use this variable wherever the script goes on.
An example is as follows:
The approximate description is as follows:
1. The function is called.
#! /Bin/shtest () {A = "1" return} testecho $
Display:
Kaiwii @ Ubuntu :~ $./TST
1
2. This function is not called.
#! /Bin/shtest () {A = "1" return} # testecho $
Display:
No
Summary:
I understand this question as follows: scripts are just calling other people's programs. People do not need to create another stack to record your layers. Therefore, when writing a shell, you only need to consider the order of the variables. As for the nested (global) relationship, let's go!
2. Usage of variable $ * and $ n
For this understanding, I would like to use a knowledge about J2EE. Write the J2EE code and get the data from the request object. Then, send the data to the following layer. The response object must be used. In J2EE, variables are transmitted through the transmission between the response object and the request object. In Shell, variables of this family are similar. When you call a function or another shell file, you can add parameters later. In these functions or another shell file, you can retrieve these parameters using the $ n variable. When accessing parameters, note the order between these parameters.
3. The value must be $
You can directly use the variable name for the value assignment. To obtain the value of this variable (A), you need to use $.