Recall & Review
beginner
What does an
until loop do in Bash scripting?An
until loop runs the commands inside it repeatedly until the given condition becomes true. It keeps running while the condition is false.Click to reveal answer
beginner
How is an
until loop different from a while loop?A
while loop runs while the condition is true. An until loop runs while the condition is false, stopping when it becomes true.Click to reveal answer
beginner
Write the basic syntax of an
until loop in Bash.until [ condition ]
do
commands
done
Click to reveal answer
beginner
What will this script print?
count=1 until [ $count -gt 3 ] do echo $count ((count++)) done
It will print:
1
2
3
The loop runs until count is greater than 3, so it prints 1, 2, and 3.
Click to reveal answer
intermediate
Why might you choose an
until loop instead of a while loop?You use
until when you want to repeat commands until a condition becomes true. It can make your code easier to read if you think in terms of "keep going until this happens."Click to reveal answer
What condition causes an
until loop to stop running?✗ Incorrect
An
until loop runs while the condition is false and stops when it becomes true.Which of these is the correct syntax to start an
until loop?✗ Incorrect
The
until loop starts with until [ condition ]; do.What will this script print?
count=5 until [ $count -lt 3 ] do echo $count ((count--)) done
✗ Incorrect
The loop runs until count is less than 3, so it prints 5, 4, and 3.
Which loop runs while the condition is true?
✗ Incorrect
A
while loop runs while the condition is true.What happens if the condition in an
until loop is true at the start?✗ Incorrect
If the condition is true at the start, the
until loop does not run.Explain how an
until loop works in Bash and give a simple example.Think about repeating something until a condition becomes true.
You got /4 concepts.
Compare and contrast
until and while loops in Bash scripting.Focus on when each loop continues and stops.
You got /4 concepts.