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.
echo
outputs a tilde, not the user's home directory path (asecho ~/.ssh/config
would do). If that is what you mean by "works", then you should not be surprised thatls
cannot list the file in a sub-directory of a directory called (literally)~
.echo
work with the$
notation andls
does not?" I.e. why can weecho $SSH_CONFIG_FILE
and see~/.ssh/config
as expected butls $SSH_CONFIG_FILE
reports an error? OP expects the unquoted$SSH_CONFIG_FILE
in thels
command to be resolved with the tilde.