2

I noticed this really weird behaviour in the macOS command line ftp client...

get index.html ~/Desktop/index.html

fails if there exists no 'index.html' on the Desktop with the error

ftp: Can't access `~/Desktop/index.html': No such file or directory

but

get index.html /Users/fweth/Desktop/index.html

succeeds! Afterwards, I can also use the first command to update the local file. Can anyone explain this to me?

3

What you are seeing is expected behavior.

The tilde (~) is a part of the shell's standard syntax that is synonymous with the user's home directory.

Tilde expansion is the process of converting these abbreviations to the directory names that they stand for.

When you are in FTP, you are not using your shell (bash, csh, zsh, etc.), rather you are using the FTP client and it has no idea what the tilde means and thusly, it cannot expand it out.

~ and HOME are the same thing. If you execute the command

$ echo ~ $HOME

You should get your home directory output twice. (The $ is for variable expansion)

/Users/fweth /Users/fweth


Trivia

The convention of using the tilde (~) derives from the Lear Siegler ADM-3A terminal that had a keyboard shortcut for the the users' HOME on the same key as the tilde.

enter image description here

  • I see, but the funny thing is that after the file has been created, I can access it via the tilde notation, also from within the ftp client... But thanks a lot for the detailed answer. – fweth Sep 20 '17 at 18:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .