Bird
0
0

Which of these conditions will keep a while loop running indefinitely in bash?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Loops
Which of these conditions will keep a while loop running indefinitely in bash?
Awhile [ $count -gt 10 ]
Bwhile [ $count -lt 5 ]
Cwhile [ $count -eq 0 ]
Dwhile true
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each condition

    Conditions with variables depend on variable values and can end.
  2. Step 2: Identify infinite condition

    The condition 'true' always returns true, so loop never ends.
  3. Final Answer:

    while true -> Option D
  4. Quick Check:

    Infinite loop condition = while true [OK]
Quick Trick: Use 'while true' for infinite loops in bash [OK]
Common Mistakes:
MISTAKES
  • Assuming variable conditions always loop infinitely
  • Using incorrect syntax for infinite loops
  • Confusing -lt and -gt operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes