In the following substitutions, braces (
{}
) are optional,
except when needed to separate a variable name from following characters
that would otherwise be a part of it.

${
var
}

The value of variable
var
.

${
var
[
i
]}

Select word or words in position
i
of
var
.
i
can be a single number, a range
m
-
n
,
a range
-
n
(missing
m
implies 1),
a range
m
-
(missing
n
implies all remaining words),
or
*
(select all words).
i
can also be a variable that
expands to one of these values.

In the table below, variables that accept values are shown
with the equal sign followed by the type of value they accept;
the value is then described. (Note, however, that variables
such as
argv
,
cwd
, or
status
are never explicitly assigned.)
For variables that are turned on
or off, the table describes what they do when set.
The C shell automatically sets the variables
argv
,
cwd
,
home
,
path
,
prompt
,
shell
,
status
,
term
, and
user
.

The C shell maintains a set of
environment variables
,
which are distinct from shell variables and aren't really part of
the C shell.
Shell variables are meaningful only within the current shell, but
environment variables are automatically exported,
making them available globally.
For example, C shell variables are accessible
only to a particular script in which they're defined, whereas
environment variables can be used
by any shell scripts, mail utilities, or editors you might invoke.

Environment variables are assigned as follows:

setenv
VAR
value

By convention, environment variable names are all uppercase.
You can create your own environment variables,
or you can use the predefined environment variables below.

These environment variables have a corresponding C shell variable.
When either one changes, the value is copied to the other:

HOME

Home directory; same as
home
.

PATH

Search path for commands; same as
path
.

TERM

Terminal type; same as
term
.

USER

User name; same as
user
.

Other environment variables include the following:

EXINIT

A string of ex commands similar to those found in
the startup
.exrc
file (e.g.,
set ai
).
Used by vi and ex.

LOGNAME

Another name for the USER variable.

MAIL

The file that holds mail. Used by mail programs.
This is not the same as the C shell
mail
variable,
which only checks for new mail.

PWD

The current directory; the value is copied from
cwd
.

SHELL

Undefined by default; once initialized to
shell
,
the two are identical.

TERMCAP

The file that holds the cursor-positioning codes for your terminal type.
Default is
/etc/termcap
.