I am following an instruction and confuse with the usage of exit
FILE=~/.bashrc
if [ -e "$FILE" ] ; then
if [ -f "$FILE" ]; then
echo "$FILE is a regular file."
fi
if [ -d "$FILE" ]; then
echo "$FILE is a directory."
fi
if [ -r "$FILE" ] ; then
echo "$FILE is readable."
fi
if [ -w "$FILE" ] ; then
echo "$FILE is writabe."
fi
if [ -x "$FILE" ]; then
echo '$FILE is executable/searchable.'
fi
else
echo '$FILE does not exist'
exit 1
fi
exit
Run and come by
$ bash test_file.sh
/Users/me/.bashrc is a regular file.
/Users/me/.bashrc is readable.
/Users/me/.bashrc is writabe.
If comment out commands of exit, the output stay unchanged.
What's its function? Could I leave out the exits when familiar with the language.