-eq 等于则为真
-ne 不等于则为真
-gt 大于则为真 -ge 大于等于则为真
-lt 小于则为真 -le 小鱼等于则为真
eg: num1=100 num2 = 100
if test $[num1] -eq $[num2]
then
echo "两数相等"
shell流程控制
在shell中,如果else没有要执行的语句就不要这个else
if else
if condition
then
command1
command2
else
command
fi
末尾要用fi就是if 倒过来的拼写
if-else -if -else
if condition1
then
command1
elif condition2
then
command
else
commandN
fi
for循环
for var in item1 item2、、、
do
command1
done
eg: for loop in 1 2 3 4 5
do
echo "the value is $loop"
done
while语句
while condition
do
command1
done
eg: int-1
while((int<=5))doechoint
done
case 语句为多选择语句,
工作方式,取值后必有单词in,每一个模式以)括号结束,一个模式一致执行到;;
case 值 in
模式1)
command1
;; 两个;;号就相当于break
模式2)
command2
;;
esac 这个为全部结束标志
eg: echo `你输入的数字为:`
read aNum
case $aNum in
1) echo `你选择了1`
;;
2) echo `你选择了2`
;;
esac