This section describes the many symbols used by tcsh. The topics are arranged as follows:
Special files
Filename metacharacters
Quoting
Command forms
Redirection forms
Characters |
Meaning |
---|---|
* |
Match any string of 0 or more characters. |
? |
Match any single character. |
[abc...] |
Match any one of the enclosed characters; a hyphen can be used to specify a range (e.g., a-z, A-Z, 0-9). |
{abc,xxx,...} |
Expand each comma-separated string inside braces. |
~ |
Home directory for the current user. |
~name |
Home directory of user name. |
Quoting disables a character's special meaning and allows it to be used literally, as itself. The characters in the following table have special meaning to tcsh.
The characters that follow can be used for quoting:
% 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
File descriptor |
Name |
Common abbreviation |
Typical default |
---|---|---|---|
0 |
Standard input |
stdin |
Keyboard |
1 |
Standard output |
stdout |
Screen |
2 |
Standard error |
stderr |
Screen |
The usual input source or output destination can be changed with redirection commands listed in the following sections.
Command |
Action |
---|---|
cmd > file |
Send output of cmd to file (overwrite). |
cmd >! file |
Same as preceding, even if noclobber is set. |
cmd >> file |
Send output of cmd to file (append). |
cmd>>! file |
Same as preceding, even if noclobber is set. |
cmd < file |
Take input for cmd from file. |
cmd << text |
Read standard input up to a line identical to text (text can be stored in a shell variable). Input usually is typed on the screen or in the shell program. Commands that typically use this syntax include cat, echo, ex, and sed. If text is enclosed in quotes, standard input will not undergo variable substitution, command substitution, etc. |
Action |
|
---|---|
cmd >& file |
Send both standard output and standard error to file. |
cmd >&! file |
Same as preceding, even if noclobber is set. |
cmd >>& file |
Append standard output and standard error to end of file. |
cmd >>&! file |
Same as preceding, even if noclobber is set. |
cmd1 |& cmd2 |
Pipe standard error together with standard output. |
(cmd> f1) >& f2 |
Send standard output to file f1 and standard error to file f2. |
cmd | tee files |
Send output of cmd to standard output (usually the screen) and to files. (See the example in Chapter 3 under tee.) |
% cat part1 > book Copy part1 to book % cat part2 part3 >> book Append parts 2 and 3 to same file as part1 % mail tim < report Take input to message from report % cc calc.c >& error_out Store all messages, including errors % cc newcalc.c >&! error_out Overwrite old file % grep Unix ch* |& pr Pipe all messages, including errors % (find / -print > filelist) >& no_access Separate error messages from list of files % sed 's/^/XX /' << "END_ARCHIVE" Supply text right after command 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"
Copyright © 2003 O'Reilly & Associates. All rights reserved.