一、shell文句,进行数据值判断。使用到shell中的关系运算符,或连接符。
关系运算符,如下:
1、-gt:大于,greater than。
2、-eq:等于,equal。
3、-lt:小于,less than。
4、-ge:大于等于,greater than or equal。
5、-le:小于等于,less than or equal。
6、-ne:不等于,not equal。
连接符,如下:
1、-a:且,and。
2、-o:或,or。
条件判断,逻辑运算符,如下:
1、&&:用来执行条件成立后执行的命令。
2、||:用来执行条件不成立后的执行命令。
二、shell文句如下。
1、大于0。
if [ $# -gt 0 ]; then
...
fi
2、等于0。
if [ $# -eq 0 ]; then
...
fi
3、小于0。
if [ $# -eq 0 ]; then
...
fi
4、大于等于0。
if [ $# -ge 0 ]; then
...
fi
if [ $# -ge 0 ] && [ $# -eq 0 ]; then
...
fi
5、小于等于0。
if [ $# -le 0 ]; then
...
fi
if [ $# -le 0 ] && [ $# -eq 0 ]; then
...
fi
6、不等于0.
if [ $# -ne 0 ]; then
...
fi
if [ $# -gt 0 ] || [ $# -lt 0 ]; then
...
fi