#!/bin/bash
if [ 0 ]
then
echo "0 is true"
else
echo "0 is flase"
fi
if [ 1 ]
then
echo "1 is true"
else
echo "1 is flase"
fi
if [ -1 ]
then
echo "-1 is true"
else
echo "-1 is flase"
fi
if [ 10 ]
then
echo "10 is true"
else
echo "10 is flase"
fi
if [ ]
then
echo "NULL is true"
else
echo "NULL is flase"
fi
if [ xyz ]
then
echo "xyz is true"
else
echo "xyz is flase"
fi
xyz=
if [ -n "$xyz" ]
then
echo "$xyz is true"
else
echo "\$xyz is flase"
fi
exit 0
# ./test.sh 輸出判斷
0 is true
1 is true
-1 is true
10 is true
NULL is flase
xyz is true
$xyz is flase