I do not understand the behaviour of this variable:
SSH_CONFIG_FILE="~/.ssh/config"
echo $SSH_CONFIG_FILE
ls -l $SSH_CONFIG_FILE
ls -l ~/.ssh/config
This is the output:
~/.ssh/config
ls: cannot access '~/.ssh/config': No such file or directory
-rw------- 1 pm domain^users 1229 Sep 19 10:52 /home/pm/.ssh/config
Why does echo work with the $ notation, and ls does not?
I tried surrounding the variable with "", '', ``, {}, [] with no improvement.
echooutputs a tilde, not the user's home directory path (asecho ~/.ssh/configwould do). If that is what you mean by "works", then you should not be surprised thatlscannot list the file in a sub-directory of a directory called (literally)~.echowork with the$notation andlsdoes not?" I.e. why can weecho $SSH_CONFIG_FILEand see~/.ssh/configas expected butls $SSH_CONFIG_FILEreports an error? OP expects the unquoted$SSH_CONFIG_FILEin thelscommand to be resolved with the tilde.