8. Tilde Expansion

Tilde expansion shorten paths. It translates the "~" character to the first matching directory. Instead of typing /home/user19/datas tilde can be used:

$ ls -d ~user19/datas
/home/user19/datas

Any characters following the tilde up to the first path separator "/" are taken together as possible login name and the home directory of this login name is substituted with "". If the login doesn't exists, its taken literal:

$ ls ~moore
ls: cannot access ~moore: No such file or directory

If no login name is given, the value of the HOME variable is substituted for "~". So, addressing own home is always done by "~/":

$ ls -d ~/datas
/home/pa/datas

If HOME is unset, the home directory of the user, who is executing the shell, is taken:

$ unset HOME
$ ls -d ~/datas
/home/pa/datas