Bird
0
0

Find the error in this script:

medium📝 Debug Q6 of 15
Bash Scripting - Loops
Find the error in this script:
for i in {1..5}
do echo $i
done
AIncorrect variable usage
BMissing semicolon after {1..5}
CMissing 'do' keyword
DNo error, script runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check for correct for loop syntax

    When 'do' is on a new line, the previous line must end with a semicolon or be properly terminated.
  2. Step 2: Identify missing semicolon

    The line 'for i in {1..5}' lacks a semicolon before newline, causing syntax error.
  3. Final Answer:

    Missing semicolon after {1..5} -> Option B
  4. Quick Check:

    Newline after for loop header needs semicolon = Missing semicolon after {1..5} [OK]
Quick Trick: Add semicolon before newline if 'do' is on next line [OK]
Common Mistakes:
MISTAKES
  • Omitting semicolon before newline
  • Thinking 'do' keyword is missing
  • Confusing variable syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes