until command is much like
while, except instead of exiting a loop when a non-zero exit status is encountered, it does the opposite. An until loop continues until it receives a 0 exit status. In our
while-count script, we continued the loop as long as the value of the
count variable was less than or equal to 5. We could get the same result by coding the script with
#!/bin/bash # until-count: display a series of numbers count=1
until [ $count -gt 5 ]; do echo $count count=$((count + 1)) done echo "Finished."
By changing the test expression to
$count -gt 5,
until will terminate the loop at the correct time. Deciding whether to use the
until loop is usually a matter of choosing the one that allows the clearest test to be written. ...