Bird
0
0

What will be the output of this script?

medium📝 Command Output Q5 of 15
Bash Scripting - Basics
What will be the output of this script?
#!/bin/bash
name="Alice"
echo "Hello, $name!"
AHello, Alice!
BHello, $name!
CHello, name!
DHello, !
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment

    The variable name is set to "Alice".
  2. Step 2: Variable expansion in echo

    The $name inside double quotes expands to "Alice".
  3. Final Answer:

    Hello, Alice! -> Option A
  4. Quick Check:

    Variable expansion with $name = Alice [OK]
Quick Trick: Use $variable inside double quotes to expand value [OK]
Common Mistakes:
MISTAKES
  • Using single quotes which prevent expansion
  • Forgetting $ before variable
  • Expecting literal $name output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes