惜风不起、唯有努力!
shell基于某个条件触发另一个条件demo(死循环)

shell基于某个条件触发另一个条件demo(死循环)

#!/bin/bash

COMMAND=$(curl -I -s -m 3 www.baidu.com |grep HTTP|awk '{print $2}')

for ((;;))
do
    sleep 1
    if [ $COMMAND -eq 302]
    then
        echo "11"
        break && exit
    else
        echo "$COMMAND"
    fi
done
#!/bin/bash

while true
do
    COMMAND=$(curl -I -s -m 3 www.baidu.com |grep HTTP|awk '{print $2}')
    sleep 1
    if [ $COMMAND -eq 302 ]
    then
        echo "$COMMAND"
        break && exit
    else
        echo "$COMMAND"
    fi
done

发表回复

您的电子邮箱地址不会被公开。