1、变量命名规则
- 变量名不能加$
- 命名只能使用英文字母、数字和下划线,首个字母不能以数字开头
- 中间不能有空格。可以有下划线
- 不能使用标点符号
- 不能使用bash中的关键字
username="tom"
引用
$username
${username}
输出
echo $username
2、只读变量
readonly 变量名
username='lishi'
readonly username
username="zs"
-bash: username: 只读变量
3、删除变量
使用unset命令可以删除变量
unset 变量名