Bird
0
0

Why does this script fail?

medium📝 Debug Q7 of 15
Bash Scripting - Variables
Why does this script fail?
echo $var
var=10
AVariable used before assignment
BVariable name is invalid
Cecho command is missing quotes
DBackslash causes syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the script

    The script echoes $var before assigning it a value.
  2. Step 2: Identify the cause of failure

    Using the variable before assignment results in an empty value being printed instead of the expected output.
  3. Final Answer:

    Variable used before assignment -> Option A
  4. Quick Check:

    Variable used before assignment = A [OK]
Quick Trick: Assign variables before using them [OK]
Common Mistakes:
MISTAKES
  • Using variables before assignment
  • Assuming variable must be assigned first
  • Missing quotes in echo

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes