bash:directories:check_if_a_directory_exists

This is an old revision of the document!


BASH - Directories - Check if a directory exists

To check if a directory exists:

if [ -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY exists.
fi

To check if a directory doesn't exist:

if [ ! -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
fi
bash/directories/check_if_a_directory_exists.1610363160.txt.gz · Last modified: 2021/01/11 11:06 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki