 |
Csh provides several ways of turning off wild card expansion
of a character or a string of characters. One way is through
quoting. Quoting allows you to prevent the shell from
considering a character or string a candidate for expansion,
as well as grouping a set of characters (usually space
separated) into a single entity.
-
First suppose somehow, we created a file in our home
directory called *, and now we wish to get rid of it. The
command, rm * would expand * to every file in our directory
which isn't good. Using the quoting character \, we could
indicate to the shell that we wish * not be expanded. So the
command rm \* would do the trick.
-
Now as another example assume we managed to create a file
called ??**?**. This time, we have a whole slew of characters
that must be quoted. In this case we wish to quote the whole
string, so we would enclose our string between two single
quotes: rm '??**?**'.
In the above example we could have also used double quotes to
exempt ??**?** from being expanded. The main difference
between using single and double quotes is that single quotes
will not expand variables or wild cards, where double quotes
will expand variables, but not wild cards.
-
Another use of quoting is grouping characters together, this
is mainly useful for tying a string of characters that
contain spaces together into a single word. For example take
the file called Mr. File, which contains a space within the
name (note: with the NeXT's File Viewer, it is really easy to
create files with spaces in them). When we try to remove the
file with the command: rm Mr. File, the shell will pass two
arguments to the rm command, Mr. and File, so rm tells us
that both Mr. and File are No such file or directory. To take
care of this we just quote the file name within quotes (both
single quotes and double quotes do the trick): rm 'Mr. File'.
-
So how do we quote the quotes? Well, just use quotes. For
example to quote the backslash, use two backslashes \\, to
quote a ", either precede the quote with a backslash or
surround it with single quotes, and visa versa for single
quotes.
-
For users of tcsh, its file completion feature will quote
special characters for you provided you give it a unique
starting pattern. If you have a file called This is the file
from Hell **** which we wanted to remove, and that was the
only file that began with the letter T, you can type rm
T<tab>, and tcsh will smartly fill out the rest for
you: This\ is\ the\ file\ from\ Hell\ \*\*\*\*, freeing you
from the worries of quoting everything. If you had another
file in the directory that began with T, then continue typing
until you have enough characters that uniquely distinguish it
from the others, then press the tab key.
|