Bird
0
0

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

medium📝 Command Output Q13 of 15
Linux CLI - Environment and Configuration
Given the commands below, what will be the output of echo $GREETING?
GREETING="Hello"
export GREETING
GREETING="Hi"
echo $GREETING
AHello
B$GREETING
CHi
DError: variable not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment and export

    First, GREETING is set to "Hello" and exported, making it available to child processes. Then GREETING is reassigned to "Hi" in the current shell.
  2. Step 2: Determine the value echoed

    The echo command prints the current value of GREETING, which is "Hi" after reassignment.
  3. Final Answer:

    Hi -> Option C
  4. Quick Check:

    Variable reassignment updates value = Hi [OK]
Quick Trick: Last assignment before echo is the value printed [OK]
Common Mistakes:
  • Thinking export freezes the variable value
  • Expecting the first assigned value to print
  • Confusing export with immediate output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes