14.11 Finding (Anyone's) Home Directory, Quickly
The C shell, ksh
and bash
have a shortcut for the pathname to your home
directory: a
tilde ( %
Bourne shell users - try the You could change your current directory to your home directory by
typing If your shell understands the tilde, it should also have an abbreviation for other users' home directories: a tilde with the username on the end. For example, the home directory for mandi , which might really be /usr3/users/mfg/mandi , could be abbreviated ~mandi . On your account, if Mandi told you to copy the file named menu.c from her src directory, you could type: %
Don't confuse this with filenames like report~
.
Some programs, like the GNU
Emacs (32.4
)
editor, create temporary filenames
that end with a The Bourne shell doesn't have anything like ~mandi . Here's a trick that's probably too ugly to type a lot - but it's useful in Bourne shell scripts, where you don't want to "hardcode" users' home directory pathnames. This command calls the C shell to put mandi 's home directory pathname into $dir : username=mandi dir=`csh -fc "echo ~$username"` The tilde is a good thing to use in your shell setup files (2.2 ) , too. - |
|