Bird
0
0

Consider the script:

medium📝 Command Output Q4 of 15
Bash Scripting - Quoting and Expansion
Consider the script:
user="Jane Doe"
echo "Welcome, $user!"
echo 'Welcome, $user!'

What will be the output when this script runs?
AWelcome, Jane Doe! Welcome, $user!
BWelcome, $user! Welcome, Jane Doe!
CWelcome, Jane Doe! Welcome, Jane Doe!
DWelcome, $user! Welcome, $user!
Step-by-Step Solution
Solution:
  1. Step 1: Double quotes expand variables

    The first echo uses double quotes, so $user is replaced by its value Jane Doe.
  2. Step 2: Single quotes prevent expansion

    The second echo uses single quotes, so $user is printed literally.
  3. Final Answer:

    Welcome, Jane Doe! Welcome, $user! -> Option A
  4. Quick Check:

    Run script to verify output matches [OK]
Quick Trick: Double quotes expand variables; single quotes do not [OK]
Common Mistakes:
MISTAKES
  • Assuming single quotes expand variables
  • Confusing output order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes