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

posted @ 2020-06-02 20:58  xd_xumaomao  阅读(116)  评论(0编辑  收藏  举报