shell break while loop 1

shell break while loop

workdone=0
while : ; do
  ...
  if [ "$workdone" -ne 0 ]; then
      break
  fi
done

Here is what the above code is Doing:
1. The while loop is executed until the condition is true.
2. The condition is true until the variable workdone is not equal to 0.
3. The variable workdone is set to 0 at the beginning of the loop.
4. The variable workdone is set to 1 if the work is done.
5. The break statement is executed if the work is done.
6. The break statement terminates the while loop.

Similar Posts