Shell/Bash: linux command if directory exists Example

By

Shell/Bash Example: This is the "linux command if directory exists" Example. compiled from many sources on the internet by SimpleTutorials.org

linux command if directory exists

DIR="/etc/httpd/"
if [ -d "$DIR" ]; then
  ### Take action if $DIR exists ###
  echo "Installing config files in ${DIR}..."
else
  ###  Control will jump here if $DIR does NOT exists ###
  echo "Error: ${DIR} not found. Can not continue."
  exit 1
fi



* Summary: This "linux command if directory exists" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others