Syntax

This section describes the many symbols peculiar to csh and tcsh. The topics are arranged as follows:

  • Special files

  • Filename metacharacters

  • Quoting

  • Command forms

  • Redirection forms

Special Files

FilenameDescription

~/.cshrc or ~/.tcshrc

Executed at each instance of shell startup. For tcsh, if no ~/.tcshrc, uses ~/.cshrc if present.

~/.login Executed by login shell after .cshrc at login.
~/.cshdirs

Executed by login shell after .login (tcsh).

~/.logout Executed by login shell at logout.
/etc/passwd Source of home directories for ~ name abbreviations.

Filename Metacharacters

CharactersMeaning
* 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.

Examples

% 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

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:

CharactersDescription
; Command separator
& Background execution
( ) Command grouping
| Pipe
* ? [ ] ~ Filename metacharacters
{ }

String expansion characters (usually don’t ...

Get Linux in a Nutshell, Third Edition 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.