When a UNIX process (command) runs, it can return a numeric status value to the process that called (started) it. The status can tell the calling process whether the command succeeded or failed. Many (but not all) UNIX commands return a status of zero if everything was okay or non-zero (1, 2, etc.) if something went wrong. A few commands, like grep and diff , return a different non-zero status for different kinds of problems; see your online manual pages to find out.
The Bourne shell puts the exit status of the previous command in the
question mark (
Of course, you usually don't have to display the exit status in this way, because there areto use the exit status of one command as a condition of further execution.
The exit status of is the status of the last command in the pipeline.  You can't test the exit status of a background job in the Bourne shell unless you use the wait command to wait for it (in effect, to bring the job out of the background).