The C shell can treat its shell variables as
They're a lot like
in other programming languages, so that's what I'll call them.
The C shell's
shell variables are arrays, for example.
By the way, arrays are great for storing information in your
shell setup files (
To set an array, use parentheses around the value.
Put a space between array members.
Inside the parentheses, you can use single quotes, backquotes, double quotes,
and so on.
Here's how to put
fix the report
in the first member of the
as the second member:
set job=("Fix the report" resign)
A dollar sign (
) before the name of a shell variable gives
you its value.
That gives all members of an array, too, because the array is
stored as a shell variable.
To pick out a particular member, put its number in square brackets
after the name.
Fix the report resign
Fix the report
Like the Bourne shell
command, the C shell
command shifts the command-line arguments.
It also shifts array members.
Let's shift the
Tom Christiansen told me that putting your
directory stack (
in an array is really useful.
You might add an
that stores the
output into an
alias pushd 'pushd \!* && set dirs=(`dirs`)'
alias popd 'popd \!* && set dirs=(`dirs`)'
Then, to look in the third directory in your stack, use a command like
Or, use an array with a
to step through the members one-by-one.
For instance, you might need to find the file
you put in some directory in your stack.
to look for a file that exists:
foreach dir ($dirs)
if (-e $dir/frobozz) echo "frobozz is in $dir"
frobozz is in /work/vol3/ch02.files/summaries