Bird
0
0

What will be the output of this script?

medium📝 Command Output Q4 of 15
Bash Scripting - User Input
What will be the output of this script?
echo "Enter your name:"
read name
echo "Hello, $name!"
AHello, (whatever user types)!
BHello, $name!
CHello, !
DSyntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand input reading

    The script prompts for input, stores it in name.
  2. Step 2: Output uses variable expansion

    echo "Hello, $name!" prints the entered name.
  3. Final Answer:

    Hello, (whatever user types)! -> Option A
  4. Quick Check:

    Variable expansion shows input [OK]
Quick Trick: Input stored in variable expands with $variable [OK]
Common Mistakes:
MISTAKES
  • Expecting literal $name output
  • Assuming syntax error without reason
  • Thinking input is not stored

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes