if [condition];then
elif[condition2]; then
else
fi
num = 3;
case $num in
1)
[cmd]
;;
case $num in
2)
[cmd]
;;
*)
[default cmd]
;;
esac
while true;do [cmd]; done;
cnt = 0; while (($cnt < 10));do [cmd];cnt = $((cnt + 1));done;
for a in {1..10}; do [cmd]; done;
这里需要注意,in与花括号之间的空格不能省略
for((i=1; i<=10; i++)); do [cmd]; done;
cnt = 0; until (($cnt > 10));do [cmd];cnt = $((cnt + 1));done;
until 和 while 相反,条件为真的时候退出。
echo "$cnt"