#! /bin/bash
echo "Please input 2 nums: "
read a b
if [ -z $b ]; then
echo b is zero !
fi
if [ -n $b ]; then
echo b is non-zero !
fi
when run the script, only input 1 number, and leave the other empty, then b is supposed to be null. but the result is both echo is printed.
-laptop:~$ ./test.sh
Pleaes input 2 nums:
5
b is zero !
b is non-zero !
b is both null and non-null ?! Could anyone comment on this ? Thanks !
~