Bird
0
0

What will be the output of this script?

medium📝 Command Output Q5 of 15
Bash Scripting - Variables
What will be the output of this script?
readonly VAR=5
unset VAR
echo $VAR
AError: cannot unset readonly variable
BEmpty line
Cunset command succeeds silently
D5
Step-by-Step Solution
Solution:
  1. Step 1: Declare VAR as readonly with value 5

    VAR is set and locked.
  2. Step 2: Attempt to unset VAR

    Unset fails with error on stderr because VAR is readonly; echo prints 5.
  3. Final Answer:

    5 -> Option D
  4. Quick Check:

    Unset readonly variable = error but output 5 [OK]
Quick Trick: Cannot unset readonly variables; value persists [OK]
Common Mistakes:
MISTAKES
  • Thinking output shows error message
  • Expecting no error on unset
  • Thinking echo prints empty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes