You can check if a directory exists in a Bash script using the -d file test operator. Here’s an example of how to do this:
#!/bin/bash
DIRECTORY="/path/to/directory"
if [ -d "$DIRECTORY" ]; then
echo "Directory exists."
else
echo "Directory does not exist."
fi
Replace /path/to/directory with the actual path of the directory you want to check. This script will output whether the specified directory exists or not.
