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:
where n is a number.
If you ...