Question 13 of 20Pro Only

Explain exit codes in Bash. What do they mean and how do you use them for error handling in scripts?

Sample answer preview

Exit codes are numeric values that commands return to indicate success or failure. They are fundamental to error handling in shell scripts. The convention is simple: zero means success, any non-zero value means failure. The special variable $?

exit code$?set -eset -o pipefailerror handlingzero success

Unlock the full answer

Get the complete model answer, key points, common pitfalls, and access to 19+ more DevOps Engineer interview questions.

Upgrade to Pro

Starting at $19/month • Cancel anytime