until
Quick Reference
Command Name:
until
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
Syntax
until test-commands; do consequent-commands; done
Options
The until
command is a shell construct rather than a standalone command with options. It doesn't have traditional command-line options like other commands. Instead, it has a specific syntax structure:
until test-commands do consequent-commands done
Where:
- test-commands: Commands that determine whether the loop continues. The loop continues until these commands return a zero exit status (success).
- consequent-commands: Commands that are executed on each iteration of the loop as long as the test-commands return a non-zero exit status (failure).
The until
loop is the logical opposite of the while
loop. While a while
loop executes as long as the condition is true, an until
loop executes as long as the condition is false.
Examples
How to Use These Examples
The examples below show common ways to use the until
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.