Bird
0
0

Which of the following is the correct syntax to exit a bash script with code 5?

easy📝 Syntax Q12 of 15
Bash Scripting - Error Handling
Which of the following is the correct syntax to exit a bash script with code 5?
Aexit 5
Bexit code 5
Cexit(5)
Dexit -5
Step-by-Step Solution
Solution:
  1. Step 1: Recall bash exit syntax

    The correct way to exit with a code is exit N, where N is a number.
  2. Step 2: Check each option

    exit 5 uses exit 5, which is valid syntax. Others are invalid in bash.
  3. Final Answer:

    exit 5 -> Option A
  4. Quick Check:

    exit N syntax = exit 5 [OK]
Quick Trick: Use just 'exit' followed by a number, no extra words [OK]
Common Mistakes:
MISTAKES
  • Adding 'code' after exit
  • Using parentheses like a function
  • Using negative numbers for exit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes