一。if结构
1.单分支结构
1
2
3
4
5
6
|
if
condition
then
statement1
statement2
...
fi
|
2.双分支结构
1
2
3
4
5
6
7
8
9
|
if
condition
then
statement1
statement2
...
else
statement3
statement4
fi
|
3.多分支结构
1
2
3
4
5
6
7
|
if
condition
then
statement
elif condition2
then
statement2
fi
|
二:case结构
1
2
3
4
5
6
7
8
9
|
case
condition
in
pattern1)
statment
;;
pattern2)
statement2
;;
....
esac
|
三:循环结构之while语句
1.当型循环结构(while)
1
2
3
4
5
6
|
while
condition
do
statement1
statement2
...
done
|
当condition为真时执行
2.直到型循环结构(until)
1
2
3
4
5
|
until condition
do
statement1
statement2
done
|
当condition满足时候结束
base提供两个循环控制语句,break:用来跳出循环控制,continue:只结束本次循环,并且开始下一轮循环。
3.foreach循环和计数型循环
1
2
3
4
5
6
|
for
var
iable
in
WordList
do
statement1
statement2
...
done
|
在结构中 in WordList可以省略,省略以后相当于in "$@"
4:C语言中的for循环结构
1
2
3
4
5
6
|
for
((exp1;exp2;exp3))
do
statment1
statment2
...
done;
|
本文转自 3147972 51CTO博客,原文链接:http://blog.51cto.com/a3147972/1287594,如需转载请自行联系原作者