Bash#

Check if file exists:#

1if [[ -f <file> ]]
2then
3    ...
4fi

… does not exist: if [[ ! -f <file> ]] or [[ ! -f <file> ]] && ...

Short:

1[[ -f <file> ]] && echo "File exists!"

Multiple files:

1if [[ -f <file1> ]] && [[ -f <file2> ]]
2then
3echo "files exist!"
4fi

Directory exists?

1if [[ -d "$DIRECTORY" ]]
2then
3    ...
4fi

or [[ -d <directory> ]] && ...