Some knowledge of variables in the shell:
Variable:
1. By default, all variables are considered to be stored as strings.
2. Variable case sensitivity
3. Add $ to the variable name before accessing the content
4. No declaration required
5. The $ extension is allowed in double quotes (replaced with the value of the variable), and the single quotation mark does not work.
Example:
S=hello # (Note that no spaces are allowed on both sides of the equals sign)
Echo $s
Environment variables:
When the shell script starts executing, some variables are initialized according to the values in the environment settings, which are environment variables. Get used to capital letters.
$HOME the home directory of the current user
$PATH a colon-separated list of directories to search for commands
The name of the shell script
$# the number of arguments passed to the script
$$ the process number of the shell script
3. Parametric variables
If the script is run with parameters, these parameter variables are created
$1,$2. Parameters of a script program
$* all the parameters to TFS to separate
[email protected] parameters are not squeezed together by $* variants
Use of variables in the shell (2)