O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Special Parameters

Some special parameters are automatically set by the Korn shell and usually cannot be directly set or modified.

The ? Parameter

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.

Table 3.4. Some Preset Special ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required