Bird
0
0

What will this Bash script output?

medium📝 Command Output Q5 of 15
Bash Scripting - Loops
What will this Bash script output?
for city in "Paris" "London"; do echo "Welcome to $city!"; done
AError: invalid syntax
BWelcome to "Paris"!\nWelcome to "London"!
CWelcome to Paris London!
DWelcome to Paris!\nWelcome to London!
Step-by-Step Solution
Solution:
  1. Step 1: Understand the loop

    The loop iterates over two strings: "Paris" and "London" (quotes are for grouping).
  2. Step 2: Echo command

    Prints 'Welcome to' followed by the city name and an exclamation mark.
  3. Final Answer:

    Welcome to Paris!\nWelcome to London! -> Option D
  4. Quick Check:

    Quotes group words but are not printed [OK]
Quick Trick: Quotes group words but don't print in output [OK]
Common Mistakes:
MISTAKES
  • Expecting quotes to appear in output
  • Concatenating all items into one line
  • Assuming syntax error due to quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes