This question already has an answer here:
I currently have a directory in a string, as such:
Note that this directory does exist. I made sure of that.
I need to check if this directory already exists, or if I need to create it. I am currently doing this using:
if [ -d $DESTDIR ]; then echo the directory exists! else echo the directory does not exist! fi
and, even though the directory does exist - I copy and pasted the name into the variable in my script - it always goes to the
else statement. Not only that, but when I do
ls $DESTDIR within the script I get a
no such file or directory error.
However, when I run
ls $DESTDIR from the command line, I get the expected result.
I've tried replacing
"$DESTDIR", but I still don't get the expected result.