Bird
0
0

Identify the error in this script:

medium📝 Debug Q7 of 15
Bash Scripting - Conditionals
Identify the error in this script:
#!/bin/bash
if [ $x -gt 10 ]; then
  echo "Greater"
else
  echo "Smaller"
AWrong comparison operator
BMissing fi to close if statement
CMissing then keyword
DNo error
Step-by-Step Solution
Solution:
  1. Step 1: Check if statement structure

    Every if statement must end with fi to close it.
  2. Step 2: Identify missing part

    The script lacks fi at the end, causing syntax error.
  3. Final Answer:

    Missing fi to close if statement -> Option B
  4. Quick Check:

    Always close if with fi [OK]
Quick Trick: Close if with fi to avoid syntax errors [OK]
Common Mistakes:
MISTAKES
  • Forgetting fi
  • Misplacing then
  • Using wrong operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes