Bird
0
0

Identify the error in this script:

medium📝 Debug Q14 of 15
Bash Scripting - Loops
Identify the error in this script:
count=1
while [ $count -lt 5 ]
  echo $count
  count=$((count + 1))
done
AWrong comparison operator '-lt'
BIncorrect variable increment syntax
CMissing 'do' keyword after while condition
DMissing closing bracket in condition
Step-by-Step Solution
Solution:
  1. Step 1: Check while loop syntax

    The while loop must have 'do' after the condition to start the loop body.
  2. Step 2: Identify missing 'do'

    The script misses 'do' after the condition line, causing syntax error.
  3. Final Answer:

    Missing 'do' keyword after while condition -> Option C
  4. Quick Check:

    while loop needs 'do' [OK]
Quick Trick: Always put 'do' after while condition [OK]
Common Mistakes:
MISTAKES
  • Omitting 'do' keyword
  • Misplacing brackets
  • Incorrect increment syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes