Answers for "shell test directory exists using test"

12

shell script to check the directory exists

Directory="/opt"
if [ -d "$Directory" ];
then
	echo -e "it's exitsn"
fi
### To check if it's not exists
if [ ! -d "$Directory" ];
then 
	echo -e "It's not theren"
fi
Posted by: Guest on December-31-2020
0

LINUX TEST FOLDER EXITS

You can use test -d (see man test).

-d file True if file exists and is a directory.

For example:

test -d "/etc" && echo Exists || echo Does not exist
Posted by: Guest on March-28-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language