Shell variable issue when trying to mkdir

bash, linux, shell, variables

Solution

The quotes prevent the expansion of ~.

Use:

CLIENT_BUILD_DIR=~/Desktop/TempDir/

if [ ! -d "$CLIENT_BUILD_DIR" ]
then mkdir "$CLIENT_BUILD_DIR"
fi

Problem

Any ideas what is wrong with this code? ``` CLIENT_BUILD_DIR="~/Desktop/TempDir/" if [ ! -d $CLIENT_BUILD_DIR ] then { mkdir $CLIENT_BUILD_DIR } fi ``` I get the error: mkdir: ~/Desktop: No such file or directory. Obviously the directory is there and the script works if I replace the variable with ~/Desktop/TempDir/

Original source