Tilde expansions
An unquoted tilde character (~) at the
beginning of a word is expanded according to the following rules:
- ~ expands to the value of the HOME
variable (the current user's home directory).
- ~user expands to the home directory of the specified user. All
the characters up to a slash (/) or the end of the
word are treated as a user name.
- ~+ expands to the value of the PWD
(working directory) variable.
- ~- expands to the value of the OLDPWD
(previous working directory) variable if it is set.
Examples
- Change the current directory to the user's home directory:
cd ~
- Change the current directory to the bin directory in user smith's home directory:
cd ~smith/bin