exit builtin

The builtin that ends the shell or script immediately with a chosen exit status, 0 for success.

In more detail

exit 1 is a general failure and exit 2 conventionally means the command was used wrongly. Without a number, exit uses the status of the last command. Any EXIT trap still runs on the way out.

Example

echo "usage: report.sh FILE" >&2; exit 2

Related terms

Taught in

References