shell——流程控制
程序员文章站
2022-06-21 17:46:33
...
1.if else
1.1 if
if condition
then
command1
command2
...
fi
1.2 if else
if condition
then
command1
command2
...
else
command3
fi
1.3
if condition1
then
command1
elif condition2
then
command2
else
command3
fi
if else语句经常与test命令结合使用,如下:
2.for
for var in item1 item2 item3
do
command1
command2
done
3.while
while condition
do
command
done
4.until
until 循环执行一系列命令直至条件为 true 时停止。
until condition
do
command
done
5.case
case val in
pattern1)
command1
;;
pattern2)
command2
;;
pattern3)
command3
;;
esac
6.跳出循环 break & continue
continue例子如下:
参考:https://www.runoob.com/linux/linux-shell-process-control.html
上一篇: OpenCV 基本图形绘制函数详解
下一篇: ZooKeeper单机伪集群搭建