Checking for a directory in shell program

by rajesh 2008-08-08 12:10:22

In shell scripting or programming we can check the availability of a directory using the following code

example 1:

if [ -d "directory path" ]
then
echo "The directory is available"
else
echo "No such directory"
fi



example 1: using test command

if ! test -d "directory path"
then
echo "The directory is available"
else
echo "No such directory"
fi

Tagged in:

1484
like
0
dislike
0
mail
flag

You must LOGIN to add comments