Bird
0
0

What will this script print?

medium📝 Command Output Q5 of 15
Bash Scripting - Loops
What will this script print?
while :; do
  echo "Hello"
  break
  echo "World"
done
AHello World
BHello
CWorld
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand loop and break

    Loop runs infinitely but 'break' exits immediately after printing 'Hello'.
  2. Step 2: Check commands after break

    Commands after break are not executed, so 'World' is not printed.
  3. Final Answer:

    Hello -> Option B
  4. Quick Check:

    Break stops loop before 'World' prints [OK]
Quick Trick: Break exits loop immediately, skipping following commands [OK]
Common Mistakes:
MISTAKES
  • Expecting both 'Hello' and 'World' to print
  • Ignoring break effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes