Bird
0
0

What will be the output of this bash script?

medium📝 Command Output Q5 of 15
Bash Scripting - Variables
What will be the output of this bash script?
var=5
var=10
echo $var
A5
B10
Cvar
DError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze variable reassignment

    The variable var is first set to 5, then reassigned to 10.
  2. Step 2: Determine final value printed

    The last assignment is 10, so echo $var outputs 10.
  3. Final Answer:

    10 -> Option B
  4. Quick Check:

    Last assignment wins = 10 [OK]
Quick Trick: Last assignment to variable is used when echoed [OK]
Common Mistakes:
MISTAKES
  • Expecting first value
  • Using $ in assignment
  • Syntax errors with spaces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes