From the course: LPI Linux Essentials (010-160) Cert Prep

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Exit value

Exit value - Linux Tutorial

From the course: LPI Linux Essentials (010-160) Cert Prep

Start my 1-month free trial

Exit value

- By now, we should have a good idea and understanding of how a script is coded. We've talked about all of the pieces and parts. However, as with any script, there is going to be a beginning, a body, and then there has to be a way to end it or exit it. In this lesson, we're going to discuss how to set up your script's exit value. Now, a script's return value is the same as the last command of the script. This means that the script is going to return dollar sign question mark. However, the exit value can be controlled, and it's possible to exit from the script at any point you want using the command, exit. Used without any options, exit is going to cause the immediate termination of the script exactly where you are, and the usual exit value of dollar sign question mark will be returned. This can be useful in error handling and aborting an ongoing operation for any reason you need. Now, if your script detects an error, or…

Contents