Bird
0
0

Identify the error in this script:

medium📝 Debug Q6 of 15
Bash Scripting - Conditionals
Identify the error in this script:
#!/bin/bash
num=5
if [ $num -lt 10 ]
  echo "Less than 10"
elif [ $num -lt 20 ]; then
  echo "Less than 20"
fi
AMissing fi at the end
BMissing then after first if condition
CIncorrect use of elif
DVariable num not declared
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax after first if condition

    After the first if condition, the keyword then is missing, which is required.
  2. Step 2: Verify other parts

    elif has then, fi is present, and variable is declared correctly.
  3. Final Answer:

    Missing then after first if condition -> Option B
  4. Quick Check:

    then keyword required after if = B [OK]
Quick Trick: Always put then after if condition [OK]
Common Mistakes:
MISTAKES
  • Omitting then after if
  • Forgetting fi
  • Misusing elif without then

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes