O'Reilly logo

Linux and Unix Shell Programming by David Tansley

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

18.1. Exit statuses

Before we get into some proper scripting, here is a quick word about exit statuses in general. Any command that is run will return an exit status. If you want to see that exit status you can use the last status command:

$ echo $?

There are four main types of exit statuses. We have already met two of them and they are the last command exit status $? and the control order commands (&&, ||). The other two are to do with exiting from a shell script or shell and exit status or return codes from a function. We will look at functions and their return codes later when we deal with functions in Chapter 19.

To exit from a current process the shell provides the command exit. The general format is:

exit n 

where n is a number.

If you ...

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