until loop
A loop that runs its body again and again until a test command succeeds, the reverse of while.
In more detail
It suits waiting for something to become ready, as in until ping -c 1 host; do sleep 1; done. Add a limit on attempts so it cannot wait forever.
Example
until [[ $tries -eq 3 ]]; do ((tries++)); doneRelated terms
- while loop — A loop that keeps repeating its block as long as a condition stays true, checking the condition before each pass.
- sleep command — The sleep command, which pauses for a number of seconds and then exits successfully.
Taught in
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation