How can I check if a directory exists in a Bash shell script?

preview_player
Показать описание
How can I check if a directory exists in a Bash shell script?

In order to check if a directory exists in Bash using shorter forms, specify the “-d” option in brackets and append the command that you want to run if it succeeds. [[ -d directory ]] && echo "This directory exists!" [ -d directory ] && echo "This directory exists!"
o check if a directory exists in a shell script and is a directory use the following syntax: [ -d "/path/to/dir" ] && echo "Directory /path/to/dir exists." [ ! -d "/path/to/dir" ] && echo "Directory /path/to/dir DOES NOT exists."
Рекомендации по теме
Комментарии
Автор

Hi there, i would like to ask about how to check the existence of hidden directory and create if there doesnt have the hidden directory there?

danielheng