Directory Naming Shorthand

Both csh and tcsh provide a shorthand notation for referring to user account home directories, and tcsh provides a shorthand for referring to entries in your directory stack.

Referring to Home Directories Using ˜name

The shell interprets ˜ or ˜name at the beginning of pathnames to mean your home directory, or the home directory for user name. These shortcuts give you a quick way to refer to any user's home directory, without typing (or even knowing) the actual pathname. Thus, if I want to see what files carl has in his home directory, I don't have to know where that directory is; I just type the following command:

% ls ˜carl

I can edit my calendar file, no matter where I am, with the following command:

% vi ˜/calendar

Suppose I'm located deep in my directory hierarchy, and I want to copy a file intro.ms.new from my Thesis directory to my current directory. I want to avoid specifying long absolute or relative paths to the file like those shown below:

% cp /usr/staff/dubois/Thesis/intro.ms.new .      (or)
% cp ../../../../Thesis/intro.ms.new .

Neither of these alternatives is attractive. The absolute path is long, and when typing a relative path it's easy to go up too few or too many levels by mistake. It's a lot simpler to type this, instead:

% cp ˜/Thesis/intro.ms.new .

If intro.ms.new is located under someone else's account, I can easily get a copy of the file by using the following command:

% cp ˜colleen/Thesis/intro.ms.new .

Referring to Directory Stack Entries ...

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.