Bird
0
0

Identify the error in this script:

medium📝 Debug Q6 of 15
Bash Scripting - Loops
Identify the error in this script:
for file in *; do echo $file done
AMissing semicolon before 'done'
BMissing 'done' keyword
CMissing quotes around $file
DMissing 'do' keyword
Step-by-Step Solution
Solution:
  1. Step 1: Check for loop syntax

    The 'for' loop syntax requires a semicolon or newline before 'done' to separate commands.
  2. Step 2: Identify missing semicolon

    In the script, 'echo $file done' is one command; missing semicolon before 'done' causes syntax error.
  3. Final Answer:

    Missing semicolon before 'done' -> Option A
  4. Quick Check:

    Semicolon needed before 'done' = D [OK]
Quick Trick: Put semicolon or newline before 'done' in loops [OK]
Common Mistakes:
MISTAKES
  • Forgetting semicolon before 'done'
  • Confusing 'do' and 'done'
  • Ignoring quotes around variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes