shell语法if else elif

来源:互联网 发布:淘宝企业店铺品牌授权 编辑:程序博客网 时间:2024/05/16 11:50
#!/bin/sh
#
# test the if .. elif .. else
#
if [ $1 -gt 0 ] ; then
echo "$1 is positive"
elif [ $1 -lt 0 ] ; then
echo "$1 is negative"
elif [ $1 -eq 0 ] ; then
echo "$1 is zero"
else
echo "$1 is not a number"
fi