csh(1) csh(1)
NAME
csh - C shell
SYNOPSIS
csh [option ...] [file [argument ...]]
DESCRIPTION
csh, the C shell, is a command interpreter like the standard (Bourne)
shell sh, and like sh it also provides the essential elements of a
programming language. The syntax of this programming language is rem-
iniscent of the C language (hence the name csh).
Like the standard Bourne shell, the C shell also supports I/O redirec-
tion and variables, command substitution, file name generation (sub-
stitution), and so on. There are, however, more options for interac-
tive use than in the Bourne shell. These include:
- completion of file names and login names,
- history substitution,
- command aliasing,
- job control
In addition, the C shell provides a number of built-in commands that
are not available in the Bourne shell.
OPTIONS
-b (break) Subsequent command-line arguments are not interpreted as
C shell options. This allows you to pass options to a shell
script without them being interpreted as options for csh.
-c When you use this option, you must specify the name of a shell
script for file. All arguments that follow file are interpreted
as arguments for file and are placed in argv, the argument-list
variable. The script is executed in a subshell.
-e (exit) Causes csh to exit immediately if a command terminates
abnormally or returns a non-zero exit status.
-f (fast start) Tells csh not to read the .cshrc file or the
-f not specified:
The .cshrc file is read at startup. If csh is started as a login
shell, the .login file is also read.
-i (interactive) Forces csh to prompt for command-line input, even
if the standard input does not appear to be a terminal.
Page 1 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
-n (no execution) csh parses (interprets), but does not execute com-
mands. This option can be used to check C shell scripts for syn-
tax errors.
-s (standard input) csh reads commands from standard input.
-t Tells csh to read and execute a single command line. A \ (back-
slash) can be used to escape newlines so as to continue the com-
mand line onto subsequent input lines.
-v (verbose) Sets the predefined variable verbose, which causes com-
mand input to be echoed on standard error after history substitu-
tion (but before other substitutions) and before command execu-
tion.
-V Tells csh to set the verbose variable before reading the .cshrc
file.
-x Sets the predefined variable echo, which causes command input to
be echoed on standard output after all substitutions and just
before command execution.
-X Tells csh to set the echo variable before reading the .cshrc
file.
file [argument ...]
file [argument ...] must not be combined with the -i, -s or -t
option. file is taken to be the name of a command or shell script
to be executed. It is passed as argument zero.
argument
Argument for the named command or script file. You may
specify more than one argument. The arguments are placed in
the argument-list variable argv.
file [argument ...] not specified:
csh reads commands from standard input.
FUNCTIONALITY AND USAGE OF THE C SHELL
This section is divided into the following subsections:
⊕ Starting and terminating the C shell
- the files .cshrc, .login and .logout
⊕ Interactive operation
- C shell prompts
- how the C shell processes the command line
Page 2 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
⊕ Non-interactive operation
⊕ File name/login name completion
⊕ Lexical analysis
- splitting the command line into words
⊕ Command line parsing
- simple commands
- pipelines
- linking pipelines
- grouping pipelines within parentheses
- commands or pipelines that run in the background
⊕ History substitution
⊕ Command aliasing
⊕ I/O redirection
⊕ Variable substitution
- creating, displaying and deleting variables
- variables used by the shell
- referencing the value of a variable
- escape characters and variable substitution
- timing of variable substitution
- shell parameters
⊕ Command substitution
⊕ File name substitution
⊕ Expressions and operators
- grouping
- arithmetic operators
- logical operators
Page 3 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
- relational operators
- file attribute inquiries
- inquiry as to the success of a command
⊕ Control flow
- loops and branches
⊕ Command execution
- how the shell searches for a command
- how commands are executed
⊕ Signal handling
⊕ Job control
- jobs and job numbers
- changing the status of jobs
- referencing a specific job
- I/O for background jobs
- status reporting by the C shell
⊕ C shell built-ins
- the built-in commands :, alias, bg, cd, chdir, dirs, echo, eval,
exec, exit, fg, glob, hashstat, history, jobs, kill, limit,
login, logout, nice, nohup, notify, onintr, popd, pushd, rehash,
repeat, set, setenv, shift, source, stop, suspend, time, umask,
unalias, unhash, unlimit, unset, unsetenv, wait, % and @.
- control-flow statements
⊕ Environment variables and predefined shell variables
⊕ C shell scripts
- the nature of C shell scripts
- starting C shell scripts
- comments
- which shell runs the script
Page 4 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Starting and terminating the C shell
When first started, the C shell normally performs commands from the
.cshrc file in your home directory (see the -f option), provided that
it is readable and you either own it or your real group ID matches its
group ID.
If the shell is invoked with a name that starts with - (as when
started by login), the shell runs as a login shell. In this case,
after executing commands from the .cshrc file, the shell executes com-
mands from the .login file in your home directory. The .login file is
subject to the same permission requirements as .cshrc. Typically, the
.login file contains commands specifying the terminal type and the
environment.
As a login C shell terminates, it performs commands from the .logout
file in your home directory; the .login file is subject to the same
permission requirements as .cshrc.
Interactive operation
After startup processing is complete, an interactive C shell displays
the prompt hostname% (for ordinary users) or hostname# (for the sys-
tem administrator). If you wish, you can change the prompt by redefin-
ing the prompt variable.
After displaying the prompt, the shell reads the commands entered at
the terminal and then processes each input line as follows:
1. It reads a line of command input and splits it into words (see
Lexical analysis).
2. It places this sequence of words on the history list (see History
substitution).
3. It then parses the sequence of words (see Command line parsing).
4. It performs alias substitution (see Command aliasing).
5. It expands history references (see History substitution).
6. It substitutes values for variables (see Variable substitution).
7. It substitutes file names for patterns (see File name substitu-
tion).
8. It redirects I/O as required (see I/O redirection).
9. It replaces commands enclosed within backquotes `...` with their
output (see Command substitution).
10. It executes the commands in the input line (see Command execution).
Page 5 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Non-interactive operation
When running non-interactively, the C shell does not display a prompt.
A non-interactive C shell can execute a command supplied as an argu-
ment on its command line, or interpret commands from a script.
File name/login name completion
If the filec variable is set accordingly, an interactive C shell can
complete a partially typed file name or login name.
- If an unambiguous partial file name is followed by an ESC charac-
ter, the shell fills in the missing characters of a matching file
name from the working directory.
- If a partial file name is followed by the EOF character <CTRL-D>,
the shell lists all matching file names in the current directory.
It then prompts once again, supplying the incomplete command line
typed in so far. You can then enter one of the listed file names.
- If the last (partial) word begins with a tilde (~) and is followed
by an ESC character, the shell attempts to complete this word with
an existing login name, rather than a file in the working directory
(see File name substitution).
If a partially entered word preceded by a tilde is followed by the
EOF character <CTRL-D>, the shell lists all matching login names.
It then prompts once again, supplying the incomplete command line
typed in so far. You can then enter one of the listed login names.
The terminal bell rings to signal errors or multiple matches; you can
suppress this by setting the nobeep variable.
You can exclude file names with certain suffixes by listing these suf-
fixes in the fignore variable. If, however, the only possible comple-
tion for a file name includes a suffix in the list, the file name in
question is not ignored. fignore does not affect the listing of file
names by the EOF character. See Examples 1 and 2 at the end of the C
shell description.
Lexical analysis
The C shell splits input lines into words according to the following
rules:
- Space and tab characters normally serve as word separators.
- The special characters &, |, ;, <, >, (, and ) form separate words;
if paired (e.g. || or >> or |&), the pairs form single words. These
shell metacharacters can be part of other words if their special
meaning is suppressed by preceding them with a backslash (e.g. a\|b
is one word; a|b forms three words).
Page 6 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
- A newline preceded by a backslash is equivalent to a space character.
- A string enclosed in matched pairs of single quotes ('...'), double
quotes ("..."), or backquotes (`...`) forms a partial word; meta-
characters in such a string (including any space or tab characters)
do not form separate words. Within pairs of single quotes, double
quotes, or backquotes, a newline preceded by a backslash is inter-
preted as a newline character (not a space).
- When the shell's input is not a terminal, the hash character #
introduces a comment that continues to the end of the input line.
All characters that form part of the comment are ignored by the
shell (see C shell scripts). The special meaning of the # character
is suppressed when it is preceded by a backslash or enclosed within
matching single or double quotes.
Example:
The following two commands
who>/tmp/whoson
who>>/tmp/whoson
comprise three words each: who, > or >>, and /tmp/whoson. However,
the command
"who am I"
is taken to be one word. The C shell interprets the word who am I
as the name of a program to be executed.
Command line parsing
The command line for the C shell is structured as follows:
- A simple command is composed of a sequence of words. The first word
(that is not part of an I/O redirection) identifies the command to
be executed. All other words with no special meaning for the C
shell are passed as arguments to the command to be executed.
- A simple command, or a set of simple commands separated by | or |&
characters, forms a pipeline. The possible combinations and their
meanings are:
command1|command2
The standard output of command1 is redirected to the standard
input of command2.
Page 7 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
command1|&command2
Both the standard output and the standard error of command1
are redirected to the standard input of command2.
- Two or more pipelines can be connected into a sequence by separat-
ing them with a colon or the character pair && or || as shown
below:
pipeline1;pipeline2
The two pipelines are executed sequentially.
pipeline1&&pipeline2
Conditional sequence in which pipeline2 is executed only if
pipeline1 is successful.
pipeline1||pipeline2
Conditional sequence in which pipeline2 is executed only if
pipeline1 is not successful.
- A pipeline or sequence of pipelines can be enclosed within paren-
theses (...) to form a simple command, which in turn may be a com-
ponent in a pipeline or a sequence of piplines.
- A sequence of pipelines will be executed asynchronously (in the
background) if an ampersand character & is appended to it; in this
case, instead of waiting for the sequence to finish before issuing
a prompt, the shell displays the job number and associated process
IDs, and prompts immediately (see Job control).
History substitution
History substitution allows you to repeat the execution of previously
entered commands or to use words from previous command lines in your
current command line. This simplifies spelling corrections and the
repetition of complicated commands.
Command lines are saved in the history list, the size of which is
governed by the value of the history variable. The most recent command
is always saved in the history list.
Each command line entry that is saved in the history list is known as
an event and is assigned an event number in ascending order.
History references may be entered anywhere on the command line, but
they cannot be nested.
Page 8 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Each history reference relates to a specific event (see Event designa-
tors). To expand a history reference, the shell searches the history
list backwards, i.e. from the last event to the first. If it finds the
required event, it selects the designated words (see Word designators)
and changes them as required (see Modifiers). The string generated in
this way is then inserted in place of the history reference on the
current command line. The resulting new command line is then placed on
the history list and also displayed on the screen. Finally, the shell
performs further substitutions such as variable substitutions, file
name substitutions, etc. and executes the command. See Examples 1 and
7 at the end of the C shell description.
History references have the following format:
______________________________________________________________________
![event-designator][:word-designator][:modifier ...]
______________________________________________________________________
! Starts a history substitution, except when followed by a space
character, a tab, a newline, an equal sign or a left parenthesis.
You can use the histchars variable to define some other character
instead of ! to begin a history substitution. The character can be
escaped with a backslash to suppress its special meaning.
In special cases history references may also begin with a caret ^
(see Quick substitution).
Event designators
An event designator is a reference to a specific command-line entry
(event) in the history list. The following event designators may be
used:
! Refers to the previous event.
Example: The history reference !! repeats the previous command.
n Refers to event number n.
-n Refers to the current event minus n.
str Refers to the most recent event starting with str.
?str[?]
Refers to the most recent event containing str.
The second ? delimiter may be omitted if a newline character
comes immediately after str.
Page 9 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Without the event designator, the history reference applies
- to the most recent command line entered, or
- to the command line referenced by an immediately preceding history
reference (if any).
The event designator may be legally omitted only if the ! which begins
the history reference is not followed by a space, a tab, a newline, an
equal sign or a left parenthesis.
Example:
!:1 !$ !:3:s/f/file/ are legal history references.
! is not a legal history reference; to repeat the execution of
the last command line entered, you must use !!.
Word designators
An event designator may optionally be followed by a word designator,
separated by a colon. The colon can be omitted if the word designator
begins with ^, $, *, - or %.
A word designator is used to select one or more words from the command
line. The following word designators are permitted:
# The entire command line typed so far.
0 The first input word (i.e. the command name).
n The nth argument.
^ The first argument (equivalent to 1).
$ The last argument.
% The word matched by the most recent ?str search.
n-m Inclusive range from nth to mth argument.
-m Abbreviation for 0-m.
n* Abbreviation for n-$.
n- Like n*, but without the last argument.
* All the arguments, or a null value if there is just one word in
the event.
Page 10 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Modifiers
After the event designator (or optional word designator), you can add
one or more modifiers. Each of these modifiers must be preceded by a
colon (except for the g modifier).
Caution: It is not possible to use modifiers on the output of command
substitutions.
There are two restrictions on modifier usage with variable
substitutions: not all of the modifiers are available, and
only one modifier is allowed per substitution.
The following modifiers are available:
h (head) Removes the last path name component, leaving the head.
t (tail) Removes all leading path name components, leaving the tail.
r (root) Removes a trailing suffix of the form .xxx leaving the
basename.
e Removes the entire path name, except for the suffix.
s/l/r[/]
Substitutes the string r for l. Unless preceded by the g modifier,
the modification is applied only to the first string that matches
l; an error is reported if no string matches.
Any character can be used as the delimiter in place of /; the del-
imiter character is automatically defined by the fact that it
immediately follows s. If you wish to use the delimiter character
in string l or r, you will need to escape it with a backslash.
The ampersand character & in the replacement string r is a meta-
character; it is replaced by the text from string l. The & can be
escaped with a backslash.
If l is a null string, a previous string is used; this string is
either the l string of the previous s command or the string str
from the previous !?str command.
The rightmost delimiter may be omitted if a newline immediately
follows r.
& Repeats the previous substitution.
g (global) This modifier may be prefixed to one of the modifiers
above, i.e. h, t, r, e, s, and & (e.g. gr or gs or g&). The change
is then applied to the first occurrence of a match in each word.
(Caution: the change is not applied to all matching strings!)
Page 11 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
p (print) The new command created by the history substitution is
placed on the history list and printed on the screen, but not exe-
cuted.
q Quotes the substituted words, escaping further substitutions.
x Like q, but splitting into words at each space character, tab or
newline.
Braces {...}
Braces can be used to insulate a history reference from subsequent
characters that are not part of the command:
!{...}string
See Example 6 at the end of the C shell description.
Quick substitution
^l^r[^]
This is the short form of the history reference !:s^l^r[^] (sub-
stitute string r for l in the previous command line or in the
command line designated by the last history reference). See Exam-
ple 7 at the end of the C shell description.
The histchars variable can be used to change the ^ (caret) for
quick substitutions to some other character.
Command aliasing
Frequently used command sequences can be abbreviated by defining
aliases for them with the C shell built-in alias.
alias alias-name alias-definition
The C shell enters the alias and the associated alias definition in a
list of aliases, which can be displayed with the alias command
(without arguments). Entries can be deleted from the list with
unalias. (See Example 8 at the end of the C shell description.)
Arguments can be specified in the alias definition as follows:
- Arguments which are constants are specified directly.
Example: alias cpr cc -c prog.c
Invoking cpr executes cc -c prog.c.
- For arguments which are to be supplied on the command line, you
must specify placeholders in the alias definition in the form of
history references. Each history reference must be escaped with a
Page 12 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
backslash to ensure that the shell expands it when expanding the
alias name, not when executing the alias command.
Example: alias gpw grep \!^ /etc/passwd
Invoking gpw anne executes grep anne /etc/passwd.
No history reference is required if the variable argument does not
need to appear within the alias definition but can simply appear
after it.
Example: alias lld ls -ld
Invoking lld dir executes ls -ld dir.
The shell resolves aliases in command lines as follows: after parsing
the command line into individual commands, the shell checks the first
word in each command. If this word is a valid alias, the shell reads
the corresponding alias definition and expands any history references
in it. The original command line with the alias is interpreted as
though it were the previously entered command. If there are no history
references in the alias definition, the shell appends the argument
list of the original command line to the alias definition (see Exam-
ples 8 and 9 at the end of the C shell description).
Aliases can be nested, i.e. an alias definition can contain the name
of another alias. Nested aliases are expanded before any history sub-
stitutions are applied. This is useful in pipelines such as
alias lm 'ls -l \!* | more'
(See Example 10 at the end of the C shell description.)
If the alias definition for an alias name1 contains some other alias
name2, then the definition of name2 must not include the alias name1,
as this would result in a loop during alias substitution. Such loops
are detected by the shell, and cause an error message.
An alias definition may also contain the name of the alias itself, but
only as the first word. This does not result in a loop, as the shell
stops after the first alias substitution in this case and does not
search for further aliases (see Example 11 at the end of the C shell
description).
I/O redirection
The expression forms below can be used to redirect a command's stan-
dard input, standard output, and standard error. File names following
the metacharacters are subjected to variable, command, and file name
substitutions separately from the rest of the command. These substitu-
tions are not carried out on the string word (see <<word).
Page 13 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
If you wish to redirect the standard output and standard error
separately, you must invoke a subshell as follows:
(command > outputfile) >& errorfile
< Redirects the standard input.
<<word
Reads the standard input, up to a line that is identical with
word, and places the resulting lines in a temporary file. Unless
word is escaped or quoted, variable and command substitutions are
performed on these lines. This means that variables are replaced
by their values, and commands enclosed in backquotes are replaced
by their output. The command for which the standard input was
redirected is then invoked with the temporary file as its stan-
dard input.
> >! >& >&!
Redirects the standard output to a file. If the file does not
exist, it is created. If it does exist, it is overwritten, and
its previous contents are lost.
If the noclobber variable is set, it prevents destruction of
existing files. It also prevents redirection to terminals and to
the null device /dev/null (the bit bucket), unless one of the !
forms is used. The & forms redirect both standard output and
standard error output to the file.
>> >>! >>& >>&!
These forms are like the> forms above, but append the standard
output to the end of an existing file rather than overwriting it.
If the noclobber variable is set and the file does not exist, the
shell will report an error, unless one of the ! forms is used.
The & forms append both standard output and standard error output
to the file.
Variable substitution
C shell variables are composed of a name and a value.
A variable name is a string of up to 20 letters, digits, and under-
scores (_), starting with a letter or an underscore. A variable's
value is a space or tab-separated list of zero or more words. If you
enclose the word list in parentheses when defining the variable, you
can access individual elements of the list with $var[index] or
${var[index]} (see Shell parameters and Example 12 at the end of the C
shell description).
Page 14 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
The C shell makes a distinction between environment variables and
shell variables: environment variables are exported automatically,
i.e. made known to invoked processes; shell variables are not (see
Environment variables and predefined shell variables). Unless expli-
citly stated otherwise, the information contained in the present sec-
tion on Variable substitution is applicable to both types of variable.
Creating, displaying, and deleting variables
The C shell built-in command set can be used to display existing vari-
ables and to define new ones; unset is used to delete variables.
Variables used by the C shell
Some variables are predefined and are maintained or used by the C
shell. For instance, the argv variable contains an image of the
shell's argument list.
Of the variables used by the shell, a number are toggles; the shell
does not care what their value is, only whether they are set or not. A
typical example of such a variable is verbose; when this variable is
set to any value (including an empty value), each command you enter is
echoed on the screen after history substitution.
Predefined variables are described in detail in the section on Envi-
ronment variables and predefined shell variables.
Referencing the value of a variable
To refer to a variable's value you precede its name with $.
$name
The expression $name represents a shell parameter. The shell replaces
parameters in the command line with the current value of the corre-
sponding variable. You can also select specific words from the vari-
able value or display other information on the variable (see Shell
parameters).
If the name of a shell parameter is followed by a letter, a digit, or
an underscore _, the shell will interpret this character as a part of
the name. Braces can be used to insulate the shell parameter from
other characters in an input-line word.
Example: The command
echo $file
can be used to display the value of the variable file (e.g.
/usr/tables/list). The command below appends the ending 00 to
the file name:
Page 15 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
mv $file ${file}00
If the braces were omitted, the shell would search for a
variable named file00, which may not have been defined.
The shell will normally report an error if you refer to an undefined
variable.
Numerical variable values can be operated on as numbers. With numeric
operations, an empty variable value is interpreted as zero; the second
and subsequent words of multiword values are ignored.
Escape characters and variable substitution
Variable substitution can be suppressed by preceding the dollar sign
with a backslash, except within double quotes ("..."), where variables
are always substituted. Variable substitution is suppressed within
single quotes ('...'). The dollar sign is also escaped if followed by
a space character, a tab or a newline.
Shell parameters in double quotes are replaced by their values; meta-
characters within the value are treated as if enclosed in single
quotes. Multiword values are expanded to a single string of words with
embedded space characters. For example, if the value of the variable
name is Anne Miller, the argument "$name" would be equivalent to "Anne
Miller".
Note the difference when the q modifier is specified with the history
reference: if the variable has a multiword value, the shell parameter
is not expanded to a single string but to a list of space-separated
words, each of which is quoted independently to prevent subsequent
command and file name substitution.
Timing of variable substitution
Variable substitution normally takes place after the input line has
been analyzed, aliases resolved, and I/O redirections applied. Excep-
tions to this are:
- variables appearing in I/O redirections and in input lines in
<<word redirections (substituted at the time the redirection is
made),
- variables appearing in backquoted commands (see Command substitu-
tion).
Command and file name substitution is not performed until values have
been substituted for variables. These substitutions are suppressed
when:
- the command or file name pattern is enclosed within double quotes,
Page 16 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
- the noglob variable is set (suppresses file name substitution
only), or
- the history reference is quoted with the history modifier q.
Shell parameters
Shell parameters are introduced by the $ character. The shell replaces
any such parameter in the command line by the current value of the
corresponding variable.
The shell parameter forms recognized by the C shell are:
$var
${var} These shell parameters are replaced by the value of the var
variable. With multiword values, the result is a space-
separated list of words.
If var is an environment variable (see Environment variables
and predefined shell variables), its value is returned (but
no history modifiers can be used).
$var[index]
${var[index]}
These shell parameters select only the indicated words from
the value of var. The value of the variable must be enclosed
in parentheses when the variable is defined (see the C shell
built-in set).
index may consist of or evaluate to a single number, a range
defined by two numbers separated by "-" (e.g. num1-num2), or
an asterisk (*). Words in the value of the variable are
indexed starting from 1; an asterisk selects all words. If
index specifies a number that exceeds the number of words in
the value of the variable, the shell will report an error. A
range may be specified in short form as follows:
-num2 short form for 1-num2;
num1- is the short form for num1-total, where total is the
total number of words in the value of the variable.
It is not an error for a range to be empty if the second
argument is omitted or lies within the permitted range 1 to
$#var.
Page 17 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
$#name
${#name} These shell parameters return the number of words in the
value of the variable.
$0 The shell parameter $0 evaluates to the name of the file from
which command input is being read. An error occurs if this
file name is not known.
$n
${n} Equivalent to $argv[n] (see the predefined shell variable
argv); n is a number greater than or equal to 1.
$* Equivalent to $argv[*] (see the predefined shell variable
argv).
$?var
${?var} Returns 1 if var is set, 0 if it is not.
$?0 Returns 1 if the current input file name is known, 0 if it is
not.
$$ Returns the process ID of the (parent) shell.
$< Substitutes a line from the standard input, with no further
interpretation thereafter. This parameter can be used to read
from the keyboard in a C shell script.
The modifiers e, h, q, r and t plus gh, gt and gr (see History substi-
tution) can be applied to the shell parameters listed below. If {...}
(braces) are used, the modifiers must appear within the braces.
$var or ${var}
$var[index] or ${var[index]}
$#name or ${#name}
$0
$n or ${n}
$*
Command substitution
A command that is enclosed in backquotes (`...`) is executed by a sub-
shell. Its standard output is split into separate words at each space
character, tab and newline; null words are discarded. Within double
quotes, only the newline character acts as a delimiter; space and tab
characters are preserved.
The resulting text replaces the backquoted string on the current com-
mand line.
A final newline character is ignored. It is therefore possible for a
command substitution to yield a partial word, even if the standard
output of the command has returned a complete line.
Page 18 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Command and file name substitutions (i.e. the substitution of command
output for backquoted commands and matching file names for patterns)
are applied selectively to the arguments of built-in commands. These
substitutions are only performed for evaluated expressions; portions
of expressions that are not evaluated are not expanded.
For external commands, file name expansion of the command name is done
separately from that of the argument list; expansion is done in a sub-
shell, after I/O redirection has taken place.
File name substitution
Unquoted words which
- contain any of the characters *, ?, [, or {
- or begin with ~ (tilde)
are treated as patterns. The shell expands these patterns as follows
(see also Example 13 at the end of the C shell description):
- Patterns featuring *, ?, or [ are replaced by an alphabetically
sorted list of file names which match the pattern and identify
existing files. The shell reports an error if there is no matching
file name for such a pattern.
- The pattern {...} is a short form for a list of strings. These
strings need not be names of existing files. The list is not
sorted.
- The patterns ~ and ~loginname represent short forms for a home
directory.
The metacharacters have the following functions:
* matches any (zero or more) characters.
? matches any single character.
[s] matches any single character contained in the enclosed string s.
[c1-c2]
matches any single character in the range from c1 to c2 inclusive
in the ASCII collating sequence.
{s1,s2,...}
expands to any of the strings (or file name matching patterns) in
the comma-separated list s1, s2,... etc. Unlike the *, ?, [s] and
[c1-c2] expressions above, the expansion of {s1,s2,...} is not
sorted.
Page 19 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
~ a short form for your home directory, as defined by the value of
the home variable.
~loginname
a short form for the home directory of the specified user, as
defined by the entry for that user in the password file
/etc/passwd.
If the above metacharacters are enclosed within single or double
quotes or preceded by a backslash, they are interpreted as normal
characters, without any special meaning.
To match a path name with a component that begins with a dot (e.g.
/usr/anne/.cshrc), the pattern must include the dot explicitly. A
slash must also be matched explicitly.
The characters { and } (left and right braces) and the string {} (an
empty pair of braces) are not expanded but are passed undisturbed.
You will find more information on file name substitution in the sec-
tion on Command substitution.
Expressions and operators
A number of C shell built-in commands accept expressions, in which the
operators are similar to those of the C programming language and fol-
low the same rules of precedence. These expressions typically appear
in the @, exit, if, set and while commands, and are often used to
regulate the flow of control for executing commands (see Control flow).
The individual components of an expression are separated by space or
tab characters. Null or missing values are treated as 0. The result of
an expression is always a string, which may be a decimal number.
The following C shell operators are grouped in order of precedence;
operators in the same line have the same precedence.
(...)
Grouping.
! Logical negation.
* / %
Multiplication, division, remainder (of integer division).
These operators are right associative, which may lead to unex-
pected results. When in doubt, you should group combinations
explicitly with parentheses.
+ - Addition, subtraction.
These operators are also right associative.
Page 20 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
<< >>
Bitwise shift left, bitwise shift right.
< > <= >=
Less than, greater than, less than or equal to, greater than or
equal to.
== != =~ !~
Equal to (==), not equal to (!=), file name substitution pattern
match (=~), file name substitution pattern mismatch (!~). These
operators compare their arguments as strings.
The operators =~ and !~ each check whether or not a string on the
left matches a file name substitution pattern on the right. This
reduces the need for switch statements in shell scripts when pat-
tern matching between strings is all that is required.
& Bitwise AND.
^ Bitwise exclusive OR (XOR)
| Bitwise inclusive OR.
&& Logical AND.
|| Logical OR.
The operators: ==, !=, =~, and !~ compare their arguments as strings;
other operators use numbers.
The following file inquiries are also available:
-r file
Returns "true" (i.e. 1) if you have read permission for file;
otherwise returns "false" (i.e. 0).
-w file
True if you have write permission for file.
-x file
True if you have execute permission for file (or search permis-
sion for a directory).
-e file
True if file exists.
-o file
True if you own the file.
-z file
True if file is of zero length (i.e. empty).
Page 21 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
-f file
True if file is a plain file.
-d file
True if file is a directory.
If file does not exist or is inaccessible, all inquiries return
"false".
There is also an inquiry to determine whether a command has completed
successfully:
{ command }
If command runs successfully, the expression evaluates to "true"
(i.e. 1). Otherwise, it evaluates to "false" (i.e. 0).
Note that commands typically return 0 when successful and some
other value if they encounter problems. If you want to inspect
the command exit status directly, you should use the value of the
status variable rather than this expression.
Control flow
The shell contains a number of built-in commands to regulate the flow
of control in scripts, and within limits, from the terminal. These
commands operate by forcing the shell either to execute a loop (e.g.
with foreach, while) or to skip a part of the input under certain con-
ditions (in a switch or if branch, etc.). See the section on C shell
built-in commands, Control-flow statements.
If the shell's input is not seekable and a loop is being read, the
input is buffered. The shell can go to certain positions within the
buffer to do the rereading implied by the loop. To the extent that
this allows, backward goto commands will succeed on nonseekable
inputs.
Command execution
If the command is a C shell built-in, the shell executes it directly.
Otherwise, the shell searches for a file by that name with execute
permission. If the command name contains a forward slash, the shell
treats it as a path name, and searches for it at the appropriate loca-
tion. If the command name does not contain a slash, the shell normally
searches through its hash table to find the file. The hash table is an
internal table maintained by the shell. It contains the path names of
all the executable files in the directories listed in the path vari-
able. The current directory constitutes an exception: the files con-
tained in it do not appear in the hash table, but are checked
separately. If the file is neither in the hash table nor in the
current directory, the shell issues a message indicating that the file
was not found.
Page 22 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
An interactive C shell will normally recreate the hash table in the
following cases:
- after it has read the .cshrc file,
- after the path variable has been reset,
- when you invoke the C shell built-in rehash.
The rehash command should be used to recompute the internal hash table
whenever the contents of directories listed in the path variable have
changed (e.g. to account for new commands added).
The hash table is used to speed up the search for the file to be exe-
cuted. It can be disabled with the csh options -c or -t, or with the C
shell built-in unhash. If this is done, the shell will check the path
variable and search for the required executable file in all the direc-
tories listed in this variable.
Special case:
If the command to be executed is a shell script that has no /
(slash) in its name, and there is an alias for the word shell,
the expansion of the shell alias is prepended (without modifica-
tion) to the command line. The system attempts to execute the
first word of this special (late-occurring) alias, which should
be a full path name. Any remaining words of the alias's defini-
tion, together with the text of the input line, are treated as
arguments.
If the file that is found has proper execute permissions, the shell
uses fork(2) to spawn a new process and passes it to the kernel
together with its arguments (using the execve(2) system call). The
kernel then attempts to overlay the new process with the chosen pro-
gram.
If the file is an executable binary [in a.out format, see a.out(4)],
the overlay succeeds, and the kernel begins executing the new process.
If the file is a text file (shell script) and its first line begins
with #!, the next word is treated as the path name of a shell (or some
other command) to be used to execute the script, and subsequent words
on the first line are interpreted as options for the named shell. The
kernel invokes (overlays) the indicated shell, using the name of the
script as an argument.
If the file is a shell script and its first line does not begin with
#!, the kernel cannot overlay the file (the execve(2) call fails). The
C shell then spawns a new shell, as follows:
- it invokes a C shell (csh) if the first line of the file begins
with a # character,
Page 23 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
- otherwise, it invokes a standard Bourne shell (sh).
The file is then executed in the newly spawned shell.
Signal handling
The C shell normally ignores QUIT signals. Background processes are
immune to signals generated from the keyboard, including hangups
(HUP). Other signals have the values that the C shell inherited from
its environment.
The shell's handling of interrupt and terminate signals within scripts
can be controlled by the C shell built-in onintr.
Login shells catch TERM signals. If the shell is not a login shell,
TERM signals are passed on to child processes. In no case are inter-
rupts allowed when a login shell is reading the .logout file.
Job control
The C shell assigns a numbered job to each command sequence or pipe-
line, to keep track of those commands that are running in the back-
ground or have been stopped with TSTP (terminal stop) signals (typi-
cally <CTRL-Z>). When a command sequence or pipeline is started in the
background using the & metacharacter, the shell displays a line with
the job number in square brackets, and a list of associated process
IDs. For example:
[1] 1234
In this example, the job has been assigned job number 1 and is associ-
ated with the top level process with process ID 1234.
You can use the jobs built-in to view the current list of jobs. The
job most recently stopped (or moved into the background if none are
stopped) is referred to as the current job, and is marked "+" in the
list. The previous job is marked "-"; when the current job is ter-
minated moved to the foreground, this job takes its place (becomes the
new current job).
To stop a running job, you must send it a stop signal (typically
<CTRL-Z>). Once the shell has reported that the job has stopped, and
has displayed the prompt, you can change the status of the job. The
built-in commands bg, fg, kill, stop and % are provided for this pur-
pose. For example, you can move the job to the background with bg,
then execute some other commands, and then return it to the foreground
with fg.
Page 24 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
Caution: When a command is restarted from a stop, the shell prints the
directory in which the command started if this is different
from the current directory. This can be misleading (i.e.
wrong), as the job may have changed directories internally.
Shell built-in commands cannot be stopped and restarted.
Command sequences in the form
command1; command2; command3
are problematical. If you suspend command2, the shell never
executes command3. This is especially noticeable if the
expansion results from an alias. You can avoid this problem
by placing the sequence in parentheses (...) to have it exe-
cuted in a subshell.
Jobs can be referenced as shown below when calling the bg, fg, kill,
stop and % commands:
% %+ %%
The current job.
%- The job previous to the current job.
%jobnumber
The job with the specified jobnumber.
Example: The command kill -9 %3 terminates job number 3.
%string
The job for which the command line begins with the specified
string. string must identify the command line uniquely.
Example: The command fg %vi brings a stopped vi job to the fore-
ground.
%?string
The job for which the command line includes string. string must
identify the command line uniquely.
A job running in the background stops when it attempts to read from
the terminal. Background jobs can normally produce output, but this
can be suppressed with the stty tostop command. A background job will
then be stopped as soon as it attempts to produce output.
Job status change reporting
While running interactively, the C shell tracks the status of each job
and reports whenever a job finishes or becomes blocked. It normally
displays a message to this effect immediately before issuing a prompt,
so as to avoid disturbing the appearance of your input. If the notify
Page 25 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
variable is set, the shell reports status changes immediately, instead
of waiting until a prompt is about to be issued. The shell built-in
notify can also be used for this purpose: notify instructs the shell
to report status changes in certain jobs immediately (see C shell
built-in commands, notify).
C shell built-in commands
Built-in commands are executed within the C shell. If a built-in com-
mand occurs as any component of a pipeline except the last, it is exe-
cuted in a subshell.
The following built-in commands are available in the C shell:
: Null command. This command is interpreted, but performs no
action.
alias [name [def]]
Assigns definition def to alias name. def is a list of words
which may contain history substitution metasyntax. These meta-
characters must be escaped with a backslash. name is not allowed
to be alias or unalias.
def not specified:
The alias name is displayed together with its current definition.
name[def] not specified:
All aliases are displayed.
See Command aliasing.
bg [job ...]
(background) Runs the specified jobs in the background. Jobs can
be referenced as described in the section on Job control.
job not specified:
The current job is run in the background (see Job control).
cd [dir]
chdir [dir]
Changes the shell's working directory to dir.
If dir is a relative path name not found in the current direc-
tory, csh will search for it in the directories listed in the
cdpath variable. If dir is the name of a shell variable whose
value starts with a slash, the current directory is changed to
the directory named by that value.
Page 26 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
dir not specified:
Changes to the user's home directory.
dirs [-l]
Prints the directory stack. The list is arranged from left to
right, with the topmost directory on the stack (the current
directory) shown on the left.
-l Produces an unabbreviated listing of all directories. Even
if the ~ notation is used to specify a directory (see File
name substitution), that directory will be listed in full.
echo [-n] list
The words in list are written to the C shell's standard output,
separated by space characters. If the -n option is not used, the
output is terminated with a newline.
-n No newline character is output at the end of the list.
eval argument ...
The C shell executes the commands which appear in the argument
list. The arguments are thus evaluated twice by the shell:
- once when the shell processes the eval command line.
- again when the shell executes the processed command-line argu-
ments as commands.
See the Bourne shell built-in eval.
exec command
Executes the specified command in place of the current shell,
which terminates.
exit [(expression)]
The shell exits with the value of expression (see Expressions and
operators).
(expression) not specified:
The shell exits with the value of the status variable.
fg [job ...]
(foreground) Brings the specified jobs into the foreground. Jobs
can be referenced as described in the section on Job control.
job not specified:
The current job is moved to the foreground (see Job control).
Page 27 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
glob wordlist
Substitutes matching file names for the patterns specified in
wordlist and then prints the word list. glob operates similarly
to echo, but does not recognize backslashes as escapes for meta-
characters. Words are delimited by NULL characters in the output.
hashstat
Prints a statistics line indicating how effective the internal
hash table has been at locating commands in the file tree (and at
avoiding exec calls in the process). In searching for commands,
an exec is attempted for each component of the path variable
- for which the hash function indicates a possible hit, and
- which does not begin with a slash.
See Command execution for more details.
history [-hr] [n]
Displays the history list; if a number n is given, only the n
most recent events are displayed.
-h Displays the history list without leading event numbers.
This is used to produce files suitable for source -h command
(see the C shell built-in source).
-r Reverses the order in which the history list is printed out
so that the most recent event is shown first rather than the
oldest event.
jobs [-l]
Lists the active jobs under job control.
-l Lists process IDs, in addition to the normal information.
kill [-signal] [pid ...] [job ...]
kill [-l]
Send the specified signal, or by default the TERM (terminate)
signal, to the specified processes or jobs. If the signal being
sent is TERM (terminate) or HUP (hangup), then the job or process
is sent a CONT (continue) signal as well. You must specify at
least one process or job; both may not be omitted.
signal Signal number or signal name.
pid Process ID.
job Jobs can be specified as described in the section on Job
control.
-l Lists the signal names that can be sent with kill.
Page 28 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
limit [-h] [resource [max-use]]
Limits consumption of the specified resource by the current pro-
cess or any process it spawns to a maximum of max-use.
If max-use is omitted, the current limit for resource is printed;
if resource is omitted, all limits are displayed.
resource
The following values can be specified for resource:
cputime Maximum amount of CPU time allowed per pro-
cess.
filesize Largest single file allowed.
datasize Maximum size of data area (including stack)
allowed for the process.
stacksize Maximum stack size allowed for the process.
coredumpsize Maximum size of a core dump file.
max-use
max-use can be given as a number, optionally followed by a
letter to indicate the scaling factor, or as a value in
minutes and seconds (for cputime):
_________________________________________________________
| resource | max-use| Meaning of max-use |
|____________________|_________|_________________________|
| cputime | n | n seconds |
| | ________|_________________________|
| | nm | n minutes |
| | ________|_________________________|
| | mm:ss | mm minutes and ss |
| | | seconds |
| | ________|_________________________|
| | nh | n hours |
|____________________|_________|_________________________|
| filesize, datasize,| n | n kilobytes |
| | ________|_________________________|
| stacksize and | nk | n kilobytes |
| | ________|_________________________|
| coredumpsize | nm | n megabytes |
|____________________|_________|_________________________|
-h Causes hard limits to be used instead of the current limits.
Hard limits impose a ceiling on values for the current lim-
its. Only the system administrator may raise the hard lim-
its.
Page 29 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
login [loginname]
login [-p]
Terminates a login shell and invokes the login command. The
.logout file is not processed. If loginname is omitted, login
prompts you for a login name.
-p Preserves the current environment (variables).
logout
Terminates a login shell.
nice [n] [command]
Increments or decrements the process priority value for the shell
or for the specified command by n.
The higher the priority value, the lower the priority of a pro-
cess, and the slower it runs. The range of process priority
values is from -20 to 20. Values of n outside this range set the
value to the lower, or to the higher boundary, respectively.
+n Increments the process priority value by n.
-n Decrements the process priority value by n. This argument
can be used only by the system administrator.
±n not specified:
The process priority value is set to 4.
command
Command for which the process priority value is to be set.
command is run in a subshell with the set value, and with
the same restrictions as apply to a command in the control-
flow statement if (expr) command.
command not specified:
nice sets the process priority value for the current shell.
nohup [command]
Runs the specified command, ignoring HUP signals. command is
always run in a subshell, and with the same restrictions as apply
to a command in the control-flow statement if (expr) command. If
no command is specified, HUP signals are ignored throughout the
remainder of a script.
Processes that are started in the background with & are always
run with nohup.
Page 30 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
notify [job ...]
Instructs the C shell to report changes in the status of the
specified jobs immediately instead of waiting until a prompt is
about to be issued. Jobs can be referenced as described in the
section on Job control.
job not specified:
Changes in the status of the current job are reported immedi-
ately. The job most recently stopped or moved into the background
(if none are stopped) is referred to as the current job.
onintr [-]
onintr [label]
Controls the actions the shell takes in response to interrupts.
No argument specified:
onintr restores the default action of the shell on inter-
rupts, i.e. the shell terminates shell scripts and waits for
command input from the terminal.
- The shell ignores all interrupts.
label
The shell executes a goto label when an interrupt is
received or a child process terminates because it was inter-
rupted.
popd [+n]
Pops the directory stack (i.e. discards its top element), and
changes to the new top directory with cd.
The elements of the directory stack are numbered from 0, starting
at the top.
+n The nth entry in the stack is discarded.
pushd [dir]
pushd [+n]
Pushes a directory onto the directory stack (i.e. adds it to the
top of the stack).
No argument specified:
Exchanges the top two stack elements and changes to the new
top directory with cd.
dir Pushes the current working directory onto the stack and
changes to dir with cd.
+n Rotates the nth entry to the top of the stack and changes to
it with cd.
Page 31 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
rehash
Recomputes the internal hash table of the contents of directories
listed in the path variable. See also Command execution.
repeat count command
Repeats the specified command count times.
command is subject to the same restrictions as apply to the
control-flow statement if (expr) command.
set [var[=value]]
set var[n]=word
No argument specified:
set displays the values of all shell variables. Multiword
values are displayed as a parenthesized list.
var set var assigns an empty (null) value to the variable var.
var=value
set var=value assigns value to the shell variable var. The
equal sign may be surrounded by white space (blanks or
tabs).
value can be any of the following:
word A single word (or a string enclosed in single or
double quotes).
(wordlist) A space-separated list of words enclosed in
parentheses. This assigns a multiword value to
var.
If value includes file name substitution metacharacters or
backquoted commands, it is subjected to file name and com-
mand substitution before being assigned to the variable.
var[n]=word
set var[n]=word replaces the nth word in the multiword value
of a shell variable (var) with word. The variable var must
be an existing variable that already has an nth word in its
value.
The square brackets are mandatory; they do not represent
optional syntax elements in this case. The equal sign may be
surrounded by white space (blanks and tabs).
As with set var=value, command and file name substitution is
performed on the value before the assignment is made.
Page 32 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
setenv [VAR [word]]
No argument specified:
setenv displays the values of all environment variables.
VAR setenv VAR assigns an empty (null) value to the environment
variable VAR.
By convention, environment variables are normally given
uppercase names.
VAR word
setenv VAR word assigns the value word, which must be either
a single word or a quoted string, to the environment vari-
able VAR.
The most commonly used environment variables, USER, TERM,
and PATH, are automatically imported to and exported from
the csh variables user, term, and path; there is no need to
use setenv for these. In addition, the shell sets the PWD
environment variable from the csh variable cwd whenever the
latter changes.
shift [var]
The components of argv, or of var if supplied, are shifted to the
left, discarding the first component.
It is an error for argv or var not to be set, or to have a null
value.
source [-h] file
The source command executes shell scripts in the current shell,
i.e. without creating a subshell. source reads commands from the
named file and executes them. source commands may be nested; how-
ever, if they are nested too deeply, the shell may run out of
file descriptors. An error in any of the shell scripts terminates
all nested source commands.
-h Places commands from file on the history list without exe-
cuting them.
stop job ...
Stops the specified background jobs. Jobs can be referenced as
described in the section on Job control.
suspend
Suspends the current shell as if it had been sent a stop signal
with <CTRL-Z>. This is most often used to stop shells started by
su.
Page 33 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
time [command]
time executes the specified command and prints a summary of the
time used by that command.
command not specified:
time prints a summary of time used by the current C shell and its
child processes.
umask [value]
umask sets or displays the current file-creation mode mask. This
mask defines the permissions to be assigned to all the files and
directories that you subsequently create in the current shell or
in any of its subshells (see the Bourne shell built-in umask).
value
A three-digit octal number specifying the file-creation mode
mask. value is XORed with the permissions of 666 for files
and 777 for directories to arrive at the permissions for new
files.
Common values for the file-creation mode mask include 002 or
022, which set the following permissions:
002 sets for files: rw-rw-r--
for directories: rwxrwxr-x
022 sets for files: rw-r--r--
for directories: rwxr-xr-x
unalias pattern
Discards all aliases that match pattern from the alias list.
pattern can be defined as any word and may include file name sub-
stitution metacharacters (see File name substitution).
unhash
Disables the internal hash table (see Command execution).
unlimit [-h] [resource]
Removes the limits from the specified resource.
resource
See limit.
resource not specified:
All resource limits are removed.
-h Removes the corresponding hard limits. This option may only
be used by the system administrator.
Page 34 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
unset pattern
Removes all shell variables whose names match pattern. pattern
can be defined as any word and may include file name substitution
metacharacters (see File name substitution).
The command unset * removes all shell variables, but may have
unwanted side-effects.
unsetenv VAR
Removes environment variable VAR from the environment. You cannot
specify a pattern for VAR as you can with unset.
wait Causes the shell to wait for all background jobs to finish (or
for an interrupt) before prompting.
%[str][&]
%str moves the job identified by %str to the foreground.
%str& leaves the job identified by %str to continue running in
the background.
str can be any of the following: +, %, -, jobnumber, string, or
?string (see Job control).
str not specified:
The current job is moved to the foreground or left running in the
background.
The command %[str] is equivalent to fg %[str].
The command %[str]& is equivalent to bg %[str].
@ [var=expr]
@ [var[n]=expr]
No argument specified:
@ displays the values of all shell variables.
var=expr
var[n]=expr
@ var=expr assigns the shell variable var the value that
expr evaluates to (see Expressions and operators).
@ var[n]=expr replaces the nth word in the multiword value
of a shell variable (var) with the value that expr evaluates
to. var and its nth component must already exist.
The square brackets are mandatory; they do not represent
optional syntax elements in this case.
Page 35 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
If expr contains the characters >, <, & or |, then these
characters or the entire expression must be placed within
parentheses (...).
The operators *=, +=, etc., are available as in C. The space
separating the variable name from the assignment operator is
optional.
In addition, you can use the special postfix operators ++
and -- to increment or decrement var by 1.
Control-flow statements
Control-flow statements are built-in commands of the C shell. The C
shell provides the following control-flow statements:
break
Exit a foreach or while loop.
breaksw
Exit from a switch statement.
continue
Continue a foreach or while loop at the next iteration.
foreach ... end
Process a list in a loop.
goto Jump to a labeled position.
if Test for a condition and execute a command.
if ... then ... else if ... then ... else ... endif
Test for conditions and execute associated commands.
switch ... case ... breaksw ... default ... breaksw ... endsw
Conditional branches.
while ... end
Loop with exit condition.
break
A break statement is used within a foreach or while loop in order
to terminate the loop. csh resumes execution after the loop's end
statement. Any remaining commands on the current line are exe-
cuted. This allows multilevel breaks to be written as a list of
break commands, all on one line, enabling you to break out of
nested loops.
breaksw
breaksw can be used within a switch statement to exit from the
switch. Execution is resumed after the associated endsw statement.
Page 36 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
continue
continue is used within a foreach or while loop; csh terminates
the current iteration of the loop and resumes execution at the
next iteration.
foreach var (wordlist)
...
end Each word in wordlist is sequentially assigned as a value to the
variable var, and the commands between foreach and end are exe-
cuted after each assignment.
The statements foreach var (wordlist) and end must appear alone
on separate lines.
There may be break and continue statements (see above) in lines
between the foreach and end statements.
If the shell reads the foreach statement from a terminal (as
opposed to a shell script), it will prompt for commands with a
query (?) before executing the commands in the foreach loop. You
may then specify additional commands in response to the query. It
is only when you enter end that the shell will execute the other
commands in the foreach loop. The commands that you enter in
response to the ? prompt are not placed on the history list.
goto label
If the label contains file name substitution metacharacters or
backquoted commands, it is first subjected to file name and com-
mand substitution to yield a label (see File name substitution
and Command substitution). The shell then looks back through its
input as far as it can, searching for a line of the form
label:
(possibly preceded by space or tab characters). Execution contin-
ues after the indicated line. It is an error to jump to a label
appearing in the body of a while or foreach loop.
if (expr) command
If expr evaluates to true, command is executed. command must be a
simple command, not a pipeline, a command list, or a parenthe-
sized command list. Variable substitution on command occurs at
the same time as it does for expr.
If command contains I/O redirection metacharacters, the redirec-
tion will occur even if expr is false.
Page 37 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
if (expr1) then
...
else if (expr2) then
...
else
...
endif
If expr1 evaluates to true, commands up to the first else are
executed, and control is passed to the statement following endif.
If expr1 is false, expr2 is evaluated.
If expr2 is true, the commands between else if and the second
else are executed, and control is passed to the statement follow-
ing endif.
If expr2 is false, commands between the second else and endif are
executed.
Any number of else if pairs are allowed, but only one else state-
ment. The endif statement is only needed once, but it is manda-
tory.
The statement if (exprX) then must appear alone on a separate
line, or after an else. The words else and endif must be the
first non-whitespace characters on a line (i.e. can only be pre-
ceded by blanks or tabs).
switch (string)
case label:
...
breaksw
...
default:
...
breaksw
endsw
If string contains file name substitution metacharacters or
backquoted commands, it is first subjected to file name and com-
mand substitution (see File name substitution and Command substi-
tution). The file name substitution metacharacters *, ? and [...]
may be used in the case labels; variables in these labels are
also substituted.
Each label is then successively matched against the specified
string. If a match is found, the commands following that label
are executed. If none of the case labels match before a default
label is found, execution begins with the commands after the
default label. If no label matches and there is no default label,
execution continues after the endsw.
Page 38 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
The breaksw statement terminates the switch statement and contin-
ues execution after the endsw.
If string matches a label and there is no breaksw between that
label and the next, commands of subsequent labels are also exe-
cuted (as in fall-through in the C programming language).
The keywords switch, case, default, and endsw must appear at the
beginning of separate lines; the default label should be speci-
fied after the case labels.
while (expr)
...
end Commands between the while statement and the matching end state-
ment are executed repeatedly as long as expr continues to evalu-
ate to true.
The while (expr) and end statements must appear alone on separate
lines.
There may be break and continue statements (see above) in lines
between the while and end statements.
If the shell reads the while statement from a terminal (as
opposed to a shell script), it will prompt for commands with a
query (?) before executing the commands in the while loop. You
may then specify additional commands in response to the query. It
is only when you enter end that the shell will execute the other
commands in the while loop. The commands that you enter in
response to the ? prompt are not placed on the history list.
Environment variables and predefined shell variables
Unlike the standard shell, the C shell maintains a distinction between
environment variables, which are automatically exported to processes
it invokes, and shell variables, which are not. Both types of vari-
ables are treated similarly in respect of variable substitution.
The C shell sets the variables argv, cwd, home, path, prompt, shell,
and status upon initialization. In addition, it copies the environment
variable USER into the shell variable user, TERM into term, and HOME
into home, and copies each back into the respective environment vari-
able whenever the shell variables are reset. PATH and path are handled
similarly; you only need to set path once in the .cshrc or .login
file. The environment variable PWD takes its value from the shell
variable cwd, changing whenever the latter changes.
The set path command can be used to remove duplicate path names from
the value of path. These may occur because a shell script or a .cshrc
file includes a command like set path=(/usr/local/usr/hosts $path) to
ensure that the named directories are added to the path name list.
Page 39 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
The following shell variables have predefined meanings:
argv Argument list containing the list of command-line arguments sup-
plied to the current invocation of the shell. This variable
governs the values of the positional parameters $1, $2, etc.:
$argv corresponds to $1 and so on.
cdpath
Contains a list of directories to be searched by the cd, chdir,
and popd commands if the directory argument they are passed is
not a subdirectory of the current directory.
cwd Contains the full path name of the current directory.
echo Setting this variable causes command input to be echoed on stan-
dard error after all substitutions and just before command execu-
tion. See the csh options -x and -X.
fignore
List of file name suffixes to be ignored when attempting file
name completion. This list typically consists of the single suf-
fix .o (see File name/login name completion).
filec
Setting the filec variable enables an interactive C shell to com-
plete partially entered file names and login names. In this case
the ESC and EOF (<CTRL-D>) characters have special significance
when typed in at the end of a terminal input line:
ESC If the string preceding ESC begins with a tilde (~), the
shell attempts to extend the string to ~login, where login
is an existing login name. If more than one name matches,
the terminal bell is rung.
If the string preceding the ESC character does not begin
with a tilde, the shell attempts to extend the string to
match a file name from the current directory. If more than
one name matches, the terminal bell is rung.
EOF If a string is followed by the EOF character, the shell
lists all matching login names or file names in the current
directory that begin with the specified string. It then
prompts once again, supplying the incomplete command line
typed in so far. You can then enter one of the listed login
names or file names.
(See File name/login name completion for more details.)
Page 40 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
hardpaths
If this variable is set, path names in the directory stack are
resolved so as to contain no symbolic-link components. This vari-
able is extremely useful, since symbolic links can confuse the C
shell.
histchars
A two-character string in which the first character defines the
initial character for history substitutions (usually the exclama-
tion point !), and the second defines the metacharacter to be
used for quick substitutions (usually the caret ^ as in ^l^r[^]).
See Quick substitution in the section on History substitution for
more details.
history
The number of lines saved in the history list. Any number may be
specified; however, a very large number may use up all the memory
that can be allocated by the C shell.
If this variable is not set, only the most recent command is
saved.
home Contains the user's home directory.
When a home directory is referenced by means of a tilde in a line
of command input, the shell refers to the value of this variable
to determine the appropriate directory (see File name substitu-
tion).
ignoreeof
If this variable is set, the shell ignores EOF characters coming
from terminals. This prevents the shell from being accidentally
terminated by someone typing <CTRL-D>.
mail A list of files which the C shell checks for incoming mail. If
the first word of the value of mail is a number n, it specifies a
mail checking interval of n seconds. If no number is specified,
mail files are checked every 5 minutes.
nobeep
Setting this variable stops the terminal bell ringing when multi-
ple matches of file names or login names are available as possi-
ble extensions for a partially entered name (see File name/login
name completion).
noclobber
Setting this variable restricts output redirection as follows: >
redirections can only be made to new files; >> redirections can
only be made to existing files (see I/O redirection).
Page 41 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
noglob
Inhibits file name substitution. This is useful in shell scripts
once the required file names have been obtained and no further
expansion is desired.
nonomatch
Returns the file name substitution pattern, rather than an error,
if the pattern cannot be matched. Patterns with an incorrect syn-
tax still result in errors.
notify
If this variable is set, the shell reports changes in the status
of jobs immediately, rather than waiting until just before issu-
ing a prompt (see Job control).
path List of directories to be searched for the appropriate file to
execute a command (see Command execution). If the value of path
is the null string, only the current directory is searched. The
default for path is typically: (. /usr/ucb /usr/bin).
If the path variable is not set, the shell will only execute com-
mands named by their absolute path names.
path is initialized from the environment variable PATH. If the
value of path changes, the shell updates the environment variable
PATH by copying the new value of path back to it.
An interactive C shell will normally hash the contents of the
directories listed in the path variable (i.e. add them to the
hash table) in the following cases:
- after it has read the .cshrc file,
- after the path variable has been reset,
- when you invoke the C shell built-in rehash.
The rehash command should be used to recompute the internal hash
table whenever the contents of directories listed in the path
variable have changed (e.g. to account for new commands added).
See Command execution.
prompt
The string an interactive C shell prompts with.
An exclamation point (!) in the prompt string is replaced by the
current event number when the prompt is displayed (see History
substitution). Note that in the set call defining the prompt you
must escape the exclamation point with a backslash to prevent the
shell from starting a history substitution (see EXAMPLES, History
substitution).
Page 42 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
The default prompt of an interactive shell is hostname% for
ordinary users, or hostname# for the system administrator.
Non-interactive C shells leave the prompt variable unset. To
reduce startup time for non-interactive shells, aliases and other
commands that are only useful interactively can be placed in the
.cshrc file conditionally on the basis of the following test:
if ($?prompt == 0) exit
(If the prompt variable is not set, i.e. if the shell is non-
interactive, exit is executed.)
savehist
The number of lines from the history list that are saved in
~/.history when the user logs out.
Large values for savehist slow down the C shell during startup.
shell
The file in which the C shell resides.
This is used in forking shells to interpret files which have exe-
cute bits set, but which are not executable by the system. See
Command execution.
status
Exit status returned by the most recent command. If that command
terminated abnormally, 0200 is added to the value of status.
Built-in commands that fail return exit status 1; all other
built-in commands set status to 0.
time Setting this variable causes the shell to display a summary of
the resources used by each command after the command terminates.
time can be given a null value or a value comprising one or two
components:
- If no value is supplied (null), the summary takes the form:
%U %S %E %P %X %D %I %O %F %W (see below).
- The first component of the value can be given as a number n,
where n is the reporting threshold in CPU seconds. This means
that the summary includes only those commands that have used
at least n CPU seconds.
- The second component of the value is a string that defines the
output format for the summary [see the format string for
printf(3S)]. The string may contain normal characters as well
as tags. Normal characters are printed unchanged. A tag is a
percent sign (%) followed by a single letter; it is replaced
Page 43 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
in the output by the value it represents. The following tags
may be specified:
%D Average amount of unshared data space used (in kilo-
bytes).
%E Elapsed time for the command (real time).
%F Page faults.
%I Number of disk block input operations.
%K Average amount of unshared stack space used (in kilo-
bytes).
%M Maximum real memory used during execution of the process.
%O Number of disk block output operations.
%P Total CPU time, i.e. %U plus %S, as a percentage of %E.
%S Number of seconds of CPU time consumed by the kernel on
behalf of the user's process (i.e. time spent in system
mode).
%U Number of seconds of CPU time devoted to the user's pro-
cess (i.e.time spent in user mode).
%W Number of swaps.
%X Average amount of shared memory used (in kilobytes).
verbose
If this variable is set, the shell displays each command after
history substitution. See the csh options -v and -V.
C shell scripts
Like the standard Bourne shell (sh), the C shell (csh) also provides
the essential elements of a programming language. This allows you to
write your own procedures known as C shell scripts.
A C shell script consists of one or more command lines. There are, in
particular, a number of built-in commands to regulate the flow of con-
trol in scripts. These commands operate by forcing the shell either to
execute a loop or to skip a part of the input under certain conditions
(see the section on C shell built-in commands, Control-flow state-
ments).
Shell scripts are usually held in files called script files, which
must have both read and execute permissions. Script files do not need
to be compiled. They are normally started with the command csh
Page 44 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
filename. When you invoke a shell script, the shell spawns a subshell,
which reads, interprets, and executes each line in the file. Once all
the commands in this file have been executed, the subshell exits and
the parent shell returns.
C shell scripts can also be started with the shell built-in source.
This command executes shell scripts in the current shell, i.e. without
spawning a subshell.
The hash character # introduces a comment that continues to the end of
the input line. All characters that make up a comment are ignored by
the shell when it processes the script.
If the first line of a shell script begins with #!, the next word is
treated as the path name of a shell (or some other command) to be used
to interpret the script. Subsequent words on the first line are
treated as options for the named shell. The kernel invokes (overlays)
the indicated shell, using the name of the script as an argument.
If the first line of the script does not begin with #!, csh then
spawns a new shell, as follows:
- it invokes a C shell (csh) if the first line of the file begins
with a # character,
- otherwise, it invokes a standard Bourne shell (sh).
The script is then executed in the newly spawned shell.
CONSTRAINTS
The C shell is subject to the following constraints:
- Words can be no longer than 1024 characters.
- The system limits argument lists to 1.048.576 characters.
- The maximum number of arguments to a command for which file name
expansion applies is 1706.
- Command substitutions may expand to an argument list containing no
more than 1.048.576 characters.
- To detect looping, the shell restricts the number of alias substi-
tutions on a single line to 20.
ERROR MESSAGES
You have stopped jobs.
You have attempted to exit the C shell with stopped jobs under job
control. An immediate second attempt to exit will succeed, terminating
the stopped jobs.
Page 45 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
FILES
~/.cshrc
File executed by the C shell at startup.
~/.login
File executed by login C shells after .cshrc at login.
~/.logout
File executed by login C shells at logout.
~/.history
File in which the history list is saved at logout for use at the
next login.
/usr/bin/sh
Standard shell. sh is a Bourne shell. Shell scripts not starting
with a # are executed by sh.
/tmp/sh*
Temporary file for << redirections (see I/O redirection).
/etc/passwd
Password file containing, among other things, the home direc-
tories needed by the C shell for evaluation of patterns in the
form ~loginname (see File name substitution).
EXAMPLES
Unless indicated otherwise, the default prompt hostname% is abbrevi-
ated to % in the following examples.
File name/login name completion
Examples 1 and 2 are based on the assumption that the filec variable
is set.
Example 1: File names
The current directory contains the files chaosnet, class, cmd,
list.old and list.new.
If you enter:
% vi ch <ESCAPE>
the shell will complete your input line with:
vi chaosnet
Page 46 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
However, if you enter:
% vi l <ESCAPE>
the shell will ring the terminal bell, since more than one file name
matches (list.old and list.new).
If you enter the EOF character instead of <ESCAPE>, all matching file
names will be listed:
% vi l <CTRL-D>
list.old list.new
% vi l
Example 2: Login names
The input line:
% cd ~ro <ESCAPE>
will be completed as:
cd ~root
if ro represents a unique abbreviation. This takes you root's home
directory.
History substitution
The examples in this section are based on the assumption that the C
shell prompt has been defined in the following way:
set prompt="\!% "
The prompt the C shell displays will then be the current event number,
followed by a percent sign and a space (see the shell variable
prompt).
The history variable should also be set to a sufficiently high value
(such as 10).
Example 3
Event designators
In the command sequence that follows, you first use the vi editor to
create a C source file called prog.c and then compile it using the C
compiler cc. As you have made a typing error, cc reports a syntax
error. You therefore edit the file again, eliminate the error, and
recompile your source with cc:
Page 47 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
1% vi prog.c
...
2% cc -O prog.c -o form
...
3% vi prog.c
...
4% cc -O prog.c -o form
5%
History substitution allows you to avoid entering the same commands
twice:
1% vi prog.c
...
2% cc -O prog.c -o form
...
3% !v or 3% !vi
vi prog.c
...
4% !c or 4% !cc or 4% !?form
cc -O prog.c -o form
5%
As you can see, the history reference !v or !vi was used in event 3.
In this case, v or vi is the event designator; it references the most
recent command entered starting with v (or vi). That command was the
command vi prog.c. The C shell prints this command line on the screen
and then executes it.
The history references !c and !cc (in event 4) are based on the same
principle and execute the command cc -O prog.c -o form in the same
way.
The history reference !?form, by contrast, achieves the same result by
designating the most recently entered command containing the string
form (at any position).
Besides using strings, you may also reference commands by their event
numbers. If you do not know which number is assigned to the command
you want in the history list, you can use the C shell built-in history
to print the list. Event numbers can be specified in absolute terms or
relative to the current event:
1% vi prog.c
...
2% cc -O prog.c -o form
...
3% history
1 vi prog.c
2 cc -O prog.c -o form
3 history
4% !1 or 4% !-3
Page 48 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
vi prog.c
...
5% !2 or 5% !-3
cc -O prog.c -o form
6%
Example 4
Word designators
________________________________________________________________________
| Most recently entered | Input line with | Input line after history|
| command | history references| substitution |
|_______________________|____________________|__________________________|
| grep ^anne /etc/passwd| grep !* | grep ^anne /etc/passwd |
| | ___________________|__________________________|
| | grep !:1 file | grep ^anne file |
| | grep !^ file | |
| | ___________________|__________________________|
| | grep ^cathy !:2 | grep ^cathy /etc/passwd |
| | grep ^cathy !$ | |
|_______________________|____________________|__________________________|
Example 5
Modifiers
________________________________________________________________________
| Most recently entered| Input line with history| Input line after |
| command | references | history substitution|
|______________________|_________________________|______________________|
| ls -l /home/anne/plan| ls -ld !$:h | ls -ld /home/anne |
| | ls -ld !$:t | ls -ld plan |
|______________________|_________________________|______________________|
| vi prog.c | cc !$ -o !$:r | cc prog.c -o prog |
| | cc !$ -o !$:s/.c/ | |
|______________________|_________________________|______________________|
| cc prog.c -o prog | !:gs/prog/list | cc list.c -o list |
| | !:s/prog/list | cc list.c -o prog |
|______________________|_________________________|______________________|
| cat f1 f2 f3 | cat !:1:s/d/file/ !:3:&| cat file1 file3 |
|______________________|_________________________|______________________|
If you are using complex history references, you should first use the
p parameter to check whether history substitution produces the desired
result before executing the command. In the case of the above example,
you could do this as follows:
1% cat f1 f2 f3
...
2% cat !:1:s/f/file/ !:3:&:p
cat file1 file3
3% !!
cat file1 file3
Page 49 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
...
4%
Example 6
Braces
___________________________________________________________________
| Most recently entered| Input line with | Input line after |
| command | history references | history substitution|
|______________________|_____________________|_____________________|
| ls -ld ~paul | !ls | The last command |
| | | beginning with ls |
| | ____________________|_____________________|
| | !{l}a | ls -ld ~paula |
| | !!a | |
| | !{!}a | |
|______________________|_____________________|_____________________|
Example 7
Quick substitution
________________________________________________________________________
| Most recently entered | Input line with | Input line after |
| command | history references| history substitution |
|________________________|____________________|_________________________|
| grep ^cathy /etc/passwd| ^ht^th | grep ^cathy /etc/passwd|
| | !:s^ht^th | |
| | !:s/ht/th | |
|________________________|____________________|_________________________|
Aliases
Example 8
Simple example
% alias lld ls -ld
% alias
...
lld (ls -ld)
...
If you enter:
% lld /usr
the shell will read the alias definition ls -ld for the alias lld and
append the argument /usr to it. This will result in the following com-
mand:
ls -ld /usr
Page 50 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
The command:
% unalias lld
removes the alias entry lld ls -ld from the alias list. The entire
alias list can be deleted with:
% unalias *
Example 9
History references in alias definitions
% alias gpw grep \!^ /etc/passwd
Due to the backslash, the shell will not expand the history reference
when executing the alias command:
% alias
gpw (grep !^ /etc/passwd)
If you now enter:
% gpw anne
the shell will read the alias definition grep !^ /etc/passwd for the
alias gpw and expand the history reference !^. For this history sub-
stitution, the shell will interpret the command gpw anne as the most
recent event, i.e. with the same effect as if you had entered the com-
mands:
gpw anne
grep !^ /etc/passwd
in that order. This means that the history reference !^ designates the
argument anne, so the resulting command would be:
grep anne /etc/passwd
Here are two more complex examples:
% alias vcc 'vi \!^; cc \!^ -o \!^:r'
% alias
vcc vi !^; cc !^ -o !^:r
The command:
% vcc prog.c
would then produce the command sequence:
vi prog.c; cc prog.c -o prog
Page 51 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
When you call the alias command, you must enclose the alias definition
in single quotes, as the shell would otherwise interpret the semicolon
as the end of the alias command instead of seeing it as a part of the
alias definition:
% alias lm 'ls -l \!* | more'
The command:
% lm dir1 dir2
would then return the pipeline:
ls -l dir1 dir2 | more
Example 10
Nested alias definitions
% alias clm 'cd \!^; lm'
% alias lm 'ls -l | more'
The command:
% clm dir
would then produce the command sequence:
cd dir; ls -l | more
Example 11
Alias definition containing the alias itself
% alias ls ls -l
The command:
% ls dir
would then expand to:
ls -l dir
Variable substitution
Example 12
The following example shows how C shell variables can be treated like
arrays in C. You can initialize the variables with a word list,
address the individual elements using subscripts, and assign values to
them.
Page 52 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
% set color=(red pink green)
% echo $color
red pink green
% echo $#color
3
% echo $color[3] $color[1] $color[2-3]
green red pink green
% set color[2]=blue
% echo $color
red blue green
To begin with, the shell variable color is assigned the word list red
pink green as its value. The second command prints the value of color.
The command echo $#color returns the number of words contained in the
value of color. The last three commands show how to address and modify
individual value components.
File name substitution
Example 13
The current directory contains the files list, plan, plan1, plan2,
plan3, and planning.
The subdirectory prog contains the files ls.c, newls.c, oldls.c and pgm.c.
______________________________________________________________
| Pattern | Expanded to |
|_______________________|_____________________________________|
| plan* | plan plan1 plan2 plan3 planning |
|_______________________|_____________________________________|
| plan? | plan1 plan2 plan3 |
|_______________________|_____________________________________|
| plan[12] | plan1 plan2 |
|_______________________|_____________________________________|
| plan[1-3] | plan1 plan2 plan3 |
|_______________________|_____________________________________|
| prog/*ls* | prog/ls.c prog/newls.c prog/oldls.c |
|_______________________|_____________________________________|
| prog/{oldls,ls,main}.c| prog/oldls.c prog/ls.c prog/main.c |
|_______________________|_____________________________________|
| ./{plan?,list} | ./plan1 ./plan2 ./plan3 ./list |
|_______________________|_____________________________________|
Note the order in the above table: when the braces are expanded, the
strings are not sorted, but when the other metacharacters are
expanded, the matching file names are sorted in alphabetical order.
Furthermore, as you can see from the second-last line in the table,
the shell expands the braces directly, i.e. without comparing the
resulting strings with the names of existing files. Consequently, the
list obtained by expanding the pattern includes a path name
prog/main.c, even though no such file exists.
Page 53 Reliant UNIX 5.44 Printed 11/98
csh(1) csh(1)
If your home directory is /home/anne, and the home directory of a user
named john is /home/john, then the patterns ~ and ~john would be
expanded as follows:
_________________________________________________________________
| Pattern | Expanded to |
|____________________|___________________________________________|
| ~/version5/prog | /home/anne/version5/prog |
|____________________|___________________________________________|
| ~john/prog | /home/john/prog |
|____________________|___________________________________________|
| ~john/prog/*.c | /home/john/prog/cls.c /home/john/prog/ls.c|
|____________________|___________________________________________|
SEE ALSO
login(1), sh(1), access(2), exec(2), fork(2), pipe(2), a.out(4),
terminfo(4), ascii(5), environ(5).
Page 54 Reliant UNIX 5.44 Printed 11/98