Sunday, June 28, 2015

Check if file or directory exists using bash or shell script sh

if [ -f file_path_name.ext ]
then
echo "file exists"
else
echo "file does not exists"
fi


if [ -d directory_path ]
then
echo "dir exists"
else
echo "dir does not exists"
fi

No comments:

Post a Comment