File name abbreviation in the C shell
The tilde (~
) and {
characters
indicate file name abbreviation. A ~
at the beginning of
a file name is used to represent home directories. Standing alone, the ~
character
expands to your home directory as reflected in the value of the home shell
variable.
For example, the following command:
ls ~
lists
all files and directories located in your $HOME directory.When the command is followed by a name consisting of
letters, digits, and hyphen (
-
) characters, the shell searches
for a user with that name and substitutes that user's $HOME directory.Note: If
the
~
character is followed by a character other than a letter
or slash (/
), or appears anywhere except at the beginning
of a word, it does not expand.To match characters in file names without typing the
entire file name, use
{ }
around the file names. The pattern a{b,c,d}e
is
another way of writing abe ace ade
. The shell preserves the
left-to-right order and separately stores the results of matches at a low
level to preserve this order. This construct might be nested. Thus, the following: ~source/s1/{oldls,ls}.c
expands to: /usr/source/s1/oldls.c /usr/source/s1/ls.c
if
the home directory for source is /usr/source.
Similarly, the following: ../{memo,*box}
might
expand to: ../memo ../box ../mbox
Note:
memo
is
not sorted with the results of matching *box
. As a special
case, the {
, }
, and { }
characters
are passed undisturbed.