Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a bash script in a busybox session.

The script has to initiate an external executable numerous times in sequence in daemonised form then monitor the output.

while read LINE; do
  VARIABLEPARAMETER=`echo "$LINE" | sed -e 's/appropriateregex(s)//'`
  externalprog --daemonize -acton $VARIABLEPARAMETER -o /tmp/outputfile.txt
  until [ "TRIGGERED" = "1" ]; do
    WATCHOUTPUT=`tail -n30 /tmp/outputfile.txt`
    TRIGGERED=`echo "$WATCHOUTPUT" | grep "keyword(s)"` 
    if [ -z "$TRIGGERED" ]; then
      PROGID=`pgrep externalprog`
      kill -2 "$PROGID"
done < /tmp/sourcedata.txt

My question is which of the two loops will the continue command be executed against?

The initial while read line, or the subsequent, until triggered?

Please don't get to focused on the actual code I've thrown this together as an example to try to explain this question, the actual code is much more detailed.

share|improve this question
up vote 5 down vote accepted

From "help continue":

continue: continue [n]
    Resume for, while, or until loops.

    Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
    If N is specified, resumes the Nth enclosing loop.

    Exit Status:
    The exit status is 0 unless N is not greater than or equal to 1.

So you want continue or continue 1 to go to the next iteration of until, or continue 2 to go to the next iteration of while.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.