Understand Exit Statuses in Bash

InstructorCameron Nokes

Share this video with your friends

Send Tweet

Every command in bash returns an exit status, which is an integer between 0 and 255 that represents whether the command succeeded or failed, and if it failed, what kind of error occurred. Functions also can return an exit status via the return keyword. The exit status can be checked using bash's special $? variable, which always stores the exit status of the last command run.