bash循环退出for循环并返回外循环

时间:2018-03-24 14:09:42

标签: bash

如何将内循环退出到外部循环并为下一个循环执行内循环?

#!/bin/bash
curl -s http://localhost | jq .consumers[] |  > /tmp/t.t # Get list of consumers
while read  consumer; do
        echo $consumer
        lag=(`curl -s http://localhost/$topic | jq '.topics."user-events"[]."offsets"[].lag' `)
                for t in ${lag[@]}
                do
                        echo "$t"

                        if [ $t -gt 100000 ]; then
                         echo "CRITICAL-  Lag on topic $topic is critical"
                         #exit 2 (I would like to move to another consumer exit the current loop )
                        elif [ $t -gt 1000 ]; then
                         echo "WARNING-  Lag on topic $topic is warning"
                         #exit 1 (I would like to move to another consumer exit the current loop )
                       else 
                        echo "OK - Lag on $topic if OK"
                        fi
                done
     #exit 0
done < /tmp/t.t }

0 个答案:

没有答案