Exit the current shell.
exit[n]
n (optional): Specified shell return value (integer).
The return value is the value of the parameter n you specify. If the parameter you specify is greater than 255 or less than 0, then the return value will always be between 0 and 255 by adding or subtracting 256.
Exit the current shell:
[root@localhost ~]# exit
logout
You can also use ctrl+d
to exit the current terminal. The following is a list of ways to turn this feature on or off:
#Open ctrl+d to exit the terminal
set -o ignoreeof
#Close ctrl+d to exit the terminal
set +o ignoreeof
In the script, enter the directory where the script is located, otherwise exit:
cd $(dirname $0) || exit 1
In the script, determine the number of parameters, print the usage method if they do not match, and exit:
if [ "$#" -ne "2" ]; then
echo "usage: $0 <area> <hours>"
exit 2
fi
In the script, delete the temporary files on exit:
trap "rm -f tmpfile; echo Bye." EXIT
Check the exit code of the previous command:
./mycommand.sh
EXCODE=$?
if [ "$EXCODE" == "0" ]; then
echo "O.K"
fi