Shell Check Directory Exists: Quick Guide

In a shell, the option -d can be used to check if a directory exists. For example, you can use the following command:

if [ -d "/path/to/directory" ]; then
    echo "Directory exists"
else
    echo "Directory does not exist"
fi

This command will check if the directory /path/to/directory exists, and will output “Directory exists” if it does, otherwise it will output “Directory does not exist”.

bannerAds