Bird
0
0

What is the output of this script?

medium📝 Command Output Q13 of 15
Bash Scripting - Loops
What is the output of this script?
for word in one two three; do echo "$word"; done
Aone two three (each on its own line)
Bone\ntwo\nthree
Cone two three
Done two three
Step-by-Step Solution
Solution:
  1. Step 1: Understand the loop iteration

    The loop runs three times, each time echoing one word: one, two, three.
  2. Step 2: Understand echo output with quotes

    Quotes preserve spaces but echo prints each word on a new line by default.
  3. Final Answer:

    one two three (each on its own line) -> Option A
  4. Quick Check:

    Echo prints each item on separate lines = A [OK]
Quick Trick: Echo prints each loop item on its own line by default [OK]
Common Mistakes:
MISTAKES
  • Thinking echo prints all items on one line
  • Confusing literal \n with newline
  • Ignoring quotes effect on output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes