January 2001
Intermediate to advanced
480 pages
7h 22m
English
Some special parameters are automatically set by the Korn shell and usually cannot be directly set or modified.
The ? parameter contains the exit status of the last executed command. In this example, the date command is executed. It ran successfully, so the exit status is 0:
$ date +%D 05/24/96 $ print $? 0
Notice that there was no output displayed from the date command. This is because the >&– I/O operator causes standard output to be closed. The next command, cp ch222.out /tmp, did not run successfully, so 1 is returned:
$ cp ch222.out /tmp ch222.out: No such file or directory $ print $? 1
When used with a pipe, $? contains the exit status of the last command in the pipeline.
Read now
Unlock full access