Bird
0
0

Identify the error in this bash snippet that checks if config.cfg exists:

medium📝 Debug Q14 of 15
Bash Scripting - File Operations in Scripts
Identify the error in this bash snippet that checks if config.cfg exists:
if [ -e config.cfg ]
  echo "Exists"
fi
AEcho command syntax is wrong
BWrong test operator -e used
CMissing closing bracket ]
DMissing then keyword after condition
Step-by-Step Solution
Solution:
  1. Step 1: Check if statement syntax

    Bash requires the then keyword after the condition in an if statement.
  2. Step 2: Identify missing part

    The snippet lacks then after [ -e config.cfg ], causing a syntax error.
  3. Final Answer:

    Missing then keyword after condition -> Option D
  4. Quick Check:

    if needs then after condition [OK]
Quick Trick: Always put then after if condition [OK]
Common Mistakes:
MISTAKES
  • Omitting then keyword
  • Forgetting semicolon before then on same line
  • Misplacing brackets

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes