Bird
0
0

What is the main purpose of a while loop in bash scripting?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Loops
What is the main purpose of a while loop in bash scripting?
ATo execute code only once
BTo repeat a block of code as long as a condition is true
CTo define a function
DTo create a variable
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of loops

    Loops repeat actions multiple times based on conditions.
  2. Step 2: Identify the while loop behavior

    A while loop runs repeatedly while its condition remains true.
  3. Final Answer:

    To repeat a block of code as long as a condition is true -> Option B
  4. Quick Check:

    while loop purpose = repeat while true [OK]
Quick Trick: While loops run code repeatedly while condition is true [OK]
Common Mistakes:
MISTAKES
  • Confusing while loop with if statement
  • Thinking while loop runs only once
  • Mixing up loop with function definition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes