Bird
0
0

Given the script:

medium📝 Command Output Q13 of 15
Bash Scripting - Quoting and Expansion
Given the script:
name="Alice"
echo "Hello, $name!"
echo 'Hello, $name!'

What is the output?
AHello, Alice! Hello, Alice!
BHello, Alice! Hello, $name!
CHello, $name! Hello, Alice!
DHello, $name! Hello, $name!
Step-by-Step Solution
Solution:
  1. Step 1: Analyze first echo with double quotes

    Double quotes expand $name to "Alice", so output is "Hello, Alice!".
  2. Step 2: Analyze second echo with single quotes

    Single quotes prevent expansion, so output is literally "Hello, $name!".
  3. Final Answer:

    Hello, Alice! Hello, $name! -> Option B
  4. Quick Check:

    Double quotes expand, single quotes do not = A [OK]
Quick Trick: Double quotes expand variables; single quotes print literally [OK]
Common Mistakes:
MISTAKES
  • Assuming single quotes expand variables
  • Confusing output order
  • Ignoring newline between echo commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes