1.条件表达式:
整数 l
== -eq
>= -ge
> -gt
<= -le
< -lt
!= -nt
2.条件语句
if [ 表达式 ]
then
elif[表达式]
then
else
fi
例子:
count=10
if [ $count -gt 10 ]
then
echo "count>10"
elif [ $count -lt 10 ]
then
echo "count<10"
else
echo "count=10"
fi
3.循环语句
while 表达式
do
echo
done
例:
declare -i count=1
while [ $count -lt 10 ]
do
echo "count="${count}
#$count = 'expr $count + 1'
#declare -i count=$count+1
count+=1
done
#-------------------------------------
for 变量 in 列表
do
done
#-------------------------------------
例:
for i in 1 2 3 4 5
do
echo "i="${i}
done
for i in {1..10} #>=1 and <=10
do
echo "ii="${i}
done
for((i=1;i<5;i++)) #两个括号
do
echo "iii="${i}
done