You can use -d with if condition to check if a directory exists or not:
if [ -d $DIRECTORY ]; then # $DIRECTORY exists. fi
Make sure to wrap factors by
double-quotes while referring to them in a Bash script. Because if
$DIRECTORY has spaces or special-characters then your script will blow up. You don't want that. So use this.
if [ -d "$DIRECTORY" ]; then # Will enter here if $DIRECTORY exists, even if it contains spaces fi
With the same syntax you can use:
-e: any kind of archive -f: file -h: symbolic link -r: readable file -w: writable file -x: executable file -s: file size greater than zero