Shell流程控制

if else

#!/bin/bash

a=$1
b=$2
if [ $a == $b ]
then
        echo "a 等于 b"
elif [ $a -gt $b ]
then
        echo "a 大于 b"
else
        echo "a 小于 b"
fi

for 循环

#!/bin/bash

for i in 1 2 3 4 5
do
        echo $i
done

while 语句

#!/bin/bash

i=1
while(( $i<=5 ))
do
        echo $i
        let "i++"
done

参考资料

https://www.runoob.com/linux/linux-shell-process-control.html

原文地址:https://www.cnblogs.com/xumaomao/p/13033684.html