Here's a bash script I'm working on:
dir="~/path/to/$1/folder"
if [ -d "$dir" ]; then
# do some stuff
else
echo "Directory $dir doesn't exist";
exit 1
fi
and when I run it from the terminal:
> ./myscript.sh 123 Directory ~/path/to/123/folder doesn't exist
But that folder clearly does exist. This works normally:
> ls ~/path/to/123/folder
What am I doing wrong?