Skip to content

Instantly share code, notes, and snippets.

@namomo
Created October 6, 2015 04:57
Show Gist options
  • Save namomo/5e05c9f26bac4119963b to your computer and use it in GitHub Desktop.
Save namomo/5e05c9f26bac4119963b to your computer and use it in GitHub Desktop.
check_condition.sh
#!/bin/sh
# To check if a directory exists in a bash shell script you can use the following:
if [ -d "$DIRECTORY" ]; then
# Will enter here if $DIRECTORY exists
fi
# Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then
# 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