bash how to quit a script

Answer

The command "exit" terminate 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. Non-zero return value is interpreted as an "error code".

If you want to get exit value last executed script use $?.

./script.sh
echo $?

Sometimes you can see exit $?, which is equivalent to exit.

Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.