Bird
0
0

Which of the following is the correct syntax to start an if-elif-else block in Bash?

easy📝 Syntax Q12 of 15
Bash Scripting - Conditionals
Which of the following is the correct syntax to start an if-elif-else block in Bash?
Aif [ condition ]; then
Bif (condition) {
Cif condition then
Dif condition:
Step-by-Step Solution
Solution:
  1. Step 1: Recall Bash if syntax

    Bash requires square brackets around conditions and 'then' after the condition, with semicolons or newlines.
  2. Step 2: Check each option

    if [ condition ]; then uses correct syntax: if [ condition ]; then. Others use wrong brackets or missing keywords.
  3. Final Answer:

    if [ condition ]; then -> Option A
  4. Quick Check:

    Correct if syntax = if [ condition ]; then [OK]
Quick Trick: Use brackets and 'then' with semicolon or newline [OK]
Common Mistakes:
MISTAKES
  • Omitting brackets around condition
  • Using parentheses instead of brackets
  • Missing 'then' keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes