/*-------------------------------------------------------------------------------------------
@ Black eyed poet <www.farwish.com>
--------------------------------------------------------------------------------------------*/
A variable is a unit of computer memory where the stored value can be changed. Variables are used to temporarily save information.
I. Variable setting rules
1. Numbers, letters, underscores, cannot start with numbers.
2.the default type of variables in bash is string type , and if you want to perform numeric operations, you must specify the variable type as numeric.
3. The variable is connected with an equal sign and cannot have spaces around the equals sign.
4. If a variable has a space, either single or double quotation marks are required, because the space represents the separator.
Name= "Chen Wei"
5. In the value of the variable, you can use the "\" escape character.
6. If you need to increase the value of the variable, then you can stack the value of the variable. However, variables need to contain "$ variable name" or ${variable name} in double quotation marks.
7. If you assign the result of the command as a variable value , you need to use the back quotation mark or the $ () containing command.
name=' ls ' or name=$ (LS)
Echo $name
8. The environment variable name is recommended capitalization, easy to distinguish.
Two. Variable classification
1. User-defined variables (also called local variables).
2. Environment variables: The data stored in the variable is related to the operating environment of the system. (value cannot be changed, can be created)
3. Positional parameter variables: used to pass parameters or data to the script, the variable name cannot be customized, the variable function is fixed. (name cannot be customized, cannot be created, can only be changed)
4. Predefined variables: The variables that are already defined in bash, variable names cannot be customized, and variables are fixed. (name cannot be customized, cannot be created, can only be changed)
Name=chenwei #变量赋值
echo $name #变量调用 (Chenwei)
Name="$name"is #变量叠加
echo $name #变量调用 (Chenweiis)
Name=${name}poet #变量叠加
echo $name #变量调用 (Chenweiispoet)
Set #变量查看
unset name #变量删除
Link:http://www.cnblogs.com/farwish/p/3923622.html
[Shell] Bash variables: Custom variables