Bird
0
0

Given the commands below, what will be the output of echo $MY_VAR?

medium📝 Command Output Q4 of 15
Linux CLI - Environment and Configuration
Given the commands below, what will be the output of echo $MY_VAR?
MY_VAR="hello"
export MY_VAR
MY_VAR="world"
Aworld
BNo output
CMY_VAR
Dhello
Step-by-Step Solution
Solution:
  1. Step 1: Trace variable assignment and export

    Initially, MY_VAR is set to "hello" and exported, making it available to child processes.
  2. Step 2: Update variable value

    MY_VAR is then changed to "world" in the current shell, so echo prints the latest value.
  3. Final Answer:

    world -> Option A
  4. Quick Check:

    Variable value updates immediately = world [OK]
Quick Trick: Last assigned value is shown by echo [OK]
Common Mistakes:
  • Assuming export freezes value
  • Printing variable name instead of value
  • Expecting no output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes