Bird
0
0

What will be the output of the following bash script?

medium📝 Command Output Q13 of 15
Bash Scripting - Variables
What will be the output of the following bash script?
name=John
echo $name
Aname
BSyntax error
CJohn
D$name
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment and usage

    The variable name is assigned the value John without spaces around =.
  2. Step 2: Understand echo with variable

    echo $name prints the value stored in name, which is John.
  3. Final Answer:

    John -> Option C
  4. Quick Check:

    Variable value printed, not variable name [OK]
Quick Trick: Use $ before variable to print its value [OK]
Common Mistakes:
MISTAKES
  • Printing variable name instead of value
  • Forgetting $ before variable in echo
  • Adding spaces around = causing errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes