#系统变量
Env View System Variables
echo $HOSTNAME View variable contents
Set view system environment variables, also display user-defined variables, compare all
#用户自定义变量
a=1;b=2 Defining variables
echo $a $b output variable value
#引用变量执行结果
Myvim= ' which vim '
#变量与数字相结合要加双引号
D= "$myvim" 3
#进入子shell, the previously defined variable does not exist
Bash
#要使用之前定义的变量, to declare globally
Export A=1
Bash
The variables defined before the Echo $a can also be used
#取消变量值
Unset D
Echo $d
Exercises
1. What are the rules that a variable name needs to conform to when customizing variables?
Variable names can contain uppercase letters
Variable names can only contain numbers, letters, and underscores
2. Which command can I use to display the variables you just defined?
Set
3. What do I need to do if I want to use a custom variable in a child shell?
Export A=1
Summarize:
Main: Global declaration variable export cancel variable value unset
1.2 Shell variables