Bash Scripting: Check if directory exists - Linux Tutorials - Learn Linux Configuration

When writing a Bash script, it is common that you’ll run into the need to check for the existence of a directory. Based on the result, your Bash script can proceed with the appropriate action.

This is a companion discussion topic for the original entry at

Just a quick note: quoting variables inside [[...]] is not necessary, you can safely use

if [[ -d $DIR ]];