Sample Header Ad - 728x90

Bash script variable syntax: with some commands it works, with others it does not

0 votes
1 answer
56 views
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.
Asked by Pietro (663 rep)
Sep 19, 2023, 02:24 PM
Last activity: Sep 19, 2023, 02:36 PM