I am puzzled about the variable substitution in shell scripting. Here is the deal: I have following script.
if [ -d ~someone/Desktop ]
then
echo exist
fi
which would determine whether user "someone" has "Desktop" directory under his home directory. However, if I substitute the someone by other variable, it will not be correct. See below,
var=someone
if [ -d ~${var}/Desktop ]
then
echo exist
fi
Although the user "someone" has Desktop directory, it will not print exist in the output. Can someone tell me why this happened?