I want to enter a directory name and check if it exists. If it does not exist, I want to create, but I get an errormkdir: cannot create directory'./' File exists
My code says that the file exists even if it does not. What am I doing wrong?
echo "Enter directory name"
read dirname
if [[ ! -d "$dirname" ]]
then
if [ -L $dirname]
then
echo "File doesn't exist. Creating now"
mkdir ./$dirname
echo "File created"
else
echo "File exists"
fi
fi
source
share