1、定义变量时, =号的两边不可以留空格
如判断变量str是否为空字符中:
if [ -z $str ];then
fi
3、字符串比较, ==两边要留空格
4、变量名不能用 -
5、if中使用test 时,不需要test ,因为 [ ] 就是判断符号
if [ test -z $str ];then
if
写成
if [ -z $str ];then
if
判断中 $str 要写成 “$str”,如果str 中有空格,就会报错
1、定义变量时, =号的两边不可以留空格
if
判断中 $str 要写成 “$str”,如果str 中有空格,就会报错