Bash How to Quit a Script
The command “exit” terminate the script and return value:
Every command returns an exit status, sometimes it is called exit code or return status.
0: Script was executed with success.
1 and greater: Script was executed with error. The non-zero return value is interpreted as an “error code”.
If you want to get the exit value last executed script use $?.
./script.sh echo $?
Sometimes you can see exit $? which is equivalent to exit.