Skip to content

Instantly share code, notes, and snippets.

@biswarupadhikari
Created August 1, 2012 20:09
Show Gist options
  • Save biswarupadhikari/3230268 to your computer and use it in GitHub Desktop.
Save biswarupadhikari/3230268 to your computer and use it in GitHub Desktop.
How to check a Directory Exist or Not In Shell Script
############ If Directory Exist ###############
if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists.
fi
############ If Directory NOT Exist ###############
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment