Edit: This is a duplicate of https://stackoverflow.com/questions/998626/meaning-of-tilde-in-linux-bash-not-home-directory/. I don't have the reputation to close this question as duplicate.
I'm not referring to
~ as in the home directory but rather this:
$ ls ~foo/bar /some/mount/point/foo/bar
However if I attempt it with a different mount point, e.g.:
$ mount | ag "/dev " devfs on /dev (devfs, local, nobrowse) $ ls /dev/stdin /dev/stdin $ ls ~stdin zsh: no such user or named directory: stdin . # bash has a similar error message: ls: ~stdin: No such file or directory
What is the
~ called in this context? How does it work?
Edit: More information based on some of the comments below:
- I can attest that
foois not a username on my system.
- When attempting to autocomplete
ls -lah ~not all options are shown. i.e. I'm able to
cd ~qux, when
quxdoesn't show up in the autocomplete. Again
quxis not a user in my system.
- If it matters
/some/mount/pointis a network share.
- All of the details suggest some named path muckery, a Z shell feature of pathname expansion, but this works in bash as well, which apparently doesn't support things like the Z shell's named paths.