Bird
0
0

What is the purpose of the elif keyword in a Bash if-elif-else statement?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Conditionals
What is the purpose of the elif keyword in a Bash if-elif-else statement?
ATo end the <code>if</code> statement
BTo start a new script block
CTo check an additional condition if the previous <code>if</code> condition is false
DTo declare a variable inside the <code>if</code> block
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of if and elif

    The if keyword checks the first condition. If it is false, elif allows checking another condition.
  2. Step 2: Differentiate elif from other keywords

    elif is not for ending or starting scripts, nor for variable declaration. It extends conditional checks.
  3. Final Answer:

    To check an additional condition if the previous if condition is false -> Option C
  4. Quick Check:

    elif extends conditions = B [OK]
Quick Trick: Use elif to add extra conditions after if [OK]
Common Mistakes:
MISTAKES
  • Thinking elif ends the if block
  • Using elif without a condition
  • Confusing elif with else

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes