Saltar al contenido principal

Exit Status Is the Contract

Interpret zero and nonzero exit statuses and use them to chain basic commands safely.

command-line-basics5 min read

The move: Read success and failure through exit status. Every serious command-line workflow eventually depends on a tiny convention: status 0 means success; nonzero means the command did not complete its intended job. Bash exposes the previous command's status as $?, and shell operators use it directly. cmd1 && cmd2 runs the second command only if the first returns zero. cmd1 || cmd2 runs the second command only if the first returns nonzero. Exit status matters because terminal output is inconsistent across tools. Some successful commands print nothing. Some failed commands print a lot. Some commands, like grep, use nonzero…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Contáctanos