Bash check if a directory exists

How to find if a directory exists in bash:

 bash | 
 
 copy code |
?

1
DIR="/etc"
2
if [ -d $DIR ]; then
3
  echo "Folder ${DIR} exists"
4
else
5
  echo "Folder ${DIR} does NOT exists"
6
fi

Leave a Reply