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 - Linux Tutorial
From the course: LPI Linux Essentials (010-160) Cert Prep
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Text files and text editors3m 55s
-
Using vi and nano8m 57s
-
(Locked)
Beginning a shell script2m 33s
-
(Locked)
Commands4m 38s
-
(Locked)
Arguments2m 35s
-
(Locked)
Variables3m 24s
-
(Locked)
Conditional expressions4m 39s
-
(Locked)
Loops and functions3m 48s
-
(Locked)
Exit value2m 17s
-
(Locked)
Turning commands into a script11m 39s
-
(Locked)
-
-
-
-
-