| You are here: SillyDog701 > UNIX Guide >SillyDog701 > UNIX Guide > (index) |
The exit statement will exit the current shell script. It can be given a numeric argument which is the script's exit status. If omitted the exit status of the last run command is used. 0 (zero) signifies success, non-zero signifies failure. For example:
#!/bin/sh if [ $# -ne 2 ] # "$#" is number of parameters- here we test # whether it is not equal to two then echo "Usage $0 \<file1\> \<file2\>" # not two parameters # so print message exit 2 # and fail ($0 is # name of command). fi ...<rest of script>
This script is supposed to take two positional arguments. It will exit with status 2 (error) rather than 0 (success) if it is not called with two parameters.
UNIX Guide home |
search |
index
| Page URL: http://sillydog.org/unix/ [SillyDog701] [Netscape] [MozInfo701] [MacCentre701] [UNIX Guide] [AntTunes701][Forums] [Search] [Change Log] [Feedback] [About Us] [Sitemap] This UNIX Guide maintained by SillyDog701, portion of this Guide is based on UNIXhelp. UNIXhelp is copyright University of Edinburgh. This page was last modified on 14 March, 2006 |
support MozInfo701 and SillyDog701 |