This subsection describes the many symbols peculiar to
the C shell. The topics are arranged as follows:
-
Special files
-
Filename metacharacters
-
Quoting
-
Command forms
-
Redirection forms
%
ls new*
Match
new
and
new.1.
%
cat ch?
Match
ch9
but not
ch10.
%
vi [D-R]*
Match files that begin with uppercase D through R.
%
ls {ch,app}?
Expand, then match
ch1
,
ch2
,
app1
,
app2.
%
cd ~tom
Change to
tom
's home directory.
Quoting disables a character's special meaning and
allows it to be used literally, as itself.
The following characters have special meaning to the C shell:
The characters below can be used for quoting:
-
$
-
Variable substitution will occur.
-
`
-
Command substitution will occur.
-
"
-
This marks the end of the double quote.
-
\
-
Escape next character.
-
!
-
The history character.
%
echo 'Single quotes "protect" double quotes'
Single quotes "protect" double quotes
%
echo "Well, isn't that \"special\"?"
Well, isn't that "special"?
%
echo "You have `ls|wc -l` files in `pwd`"
You have 43 files in /home/bob
%
echo "The value of \$x is $x"
The value of $x is 100
%
nroff file &
Format in the background.
%
cd; ls
Execute sequentially.
%
(date; who; pwd) > logfile
All output is redirected.
%
sort file | pr -3 | lp
Sort file, page output, then print.
%
vi `grep -l ifdef *.c`
Edit files found by grep.
%
egrep '(yes|no)' `cat list`
Specify a list of files to search.
%
grep XX file && lp file
Print file if it contains the pattern,
%
grep XX file || echo XX not found
otherwise, echo an error message.
The usual input source or output destination can
be changed as follows:
%
cat part1 > book
%
cat part2 part3 >> book
%
mail tim < report
%
cc calc.c >& error_out
%
cc newcalc.c >&! error_out
%
grep UNIX ch* |& pr
%
(find / -print > filelist) >& no_access
%
sed 's/^/XX /g' << "END_ARCHIVE"
This is often how a shell archive is "wrapped",
bundling text for distribution. You would normally
run sed from a shell program, not from the command line.
"END_ARCHIVE"
XX This is often how a shell archive is "wrapped",
XX bundling text for distribution. You would normally
XX run sed from a shell program, not from the command line.
|