8 var1='hello'
9 var2=''
10 if [ -n $var1 ];then
11 echo $?
12 echo "the string '$var1' is not empty"
13 else
14 echo "the string '$var1' is empty"
15 fi
16
17 if [ -n $var2 ];then
18 echo "the string '$var2' is not empty"
19 else
20 echo "the string '$var2' is empty"
21 fi
the out put is
0
the string 'hello' is not empty
the string '' is not empty
$var2 should be empty, I can't understand why command " -n $var1 " in line 17 made line 18 done. Could you help me?
Thanks!
9 var2=''
10 if [ -n $var1 ];then
11 echo $?
12 echo "the string '$var1' is not empty"
13 else
14 echo "the string '$var1' is empty"
15 fi
16
17 if [ -n $var2 ];then
18 echo "the string '$var2' is not empty"
19 else
20 echo "the string '$var2' is empty"
21 fi
the out put is
0
the string 'hello' is not empty
the string '' is not empty
$var2 should be empty, I can't understand why command " -n $var1 " in line 17 made line 18 done. Could you help me?
Thanks!