Introduction
Custom exit codes help your script tell other programs or users what happened when it finished.
exit N
exit 0exit 1exit 42#!/bin/bash # Check if a file exists if [ -f "$1" ]; then echo "File exists." exit 0 else echo "File does not exist." exit 2 fi
exit 0 mean in a bash script?exit 0 means the script ended without any errors.exit N, where N is a number.exit 5, which is valid syntax. Others are invalid in bash.#!/bin/bash if [ -f "/tmp/file.txt" ]; then exit 3 else exit 0 fi
-f.#!/bin/bash exit 256
$UID -ne 0 means user is not root.Pass the test and this pattern moves unknown