6.5. Tilde SubstitutionAny token of the form ~name is subject to tilde substitution. The shell checks the password file to see if name is a valid user name, and if it is, replaces the ~name sequence with the full pathname of the user's home directory. If it isn't, the ~name sequence is left unchanged. Tilde substitution occurs after aliases are processed. Figure 6-21 is a table of the tilde substitutions, including the special cases ~+ and ~-:
The predefined local variables PWD and OLDPWD are described later in this chapter. Here are some examples of tilde substitution: $ pwd /home/glass ...current working directory. $ echo ~ /home/glass ...my home directory. $ cd / ...change to root directory. $ echo ~+ / ...current working directory. $ echo ~- /home/glass ...previous working directory. $ echo ~dcox /home/dcox ...another user's home directory. $ _ |