基本语法
[ condition ] 注意condition前后要有空格。非空返回0,0为 true,否则为false 。
代码列子:
num1=1;
num2=3;
if [ ${num1}>${num2} ]
then
echo "${num1}>${num2}"
elif [ ${num1}<${$num2} ]
then
echo "${num1}<${$num2}"
elif [ ${num1}==${num2} ]
then
echo "${num1}=${num2}"
else
echo "不符合"
fi
输出结果:1>3