5.3 VariablesThis subsection describes the following:
5.3.1 Variable Substitution
In the following substitutions, braces (
5.3.1.1 ExamplesSort the third through last arguments (files) and save the output in a unique temporary file:
sort $argv[3-] > tmp.$$ Process .cshrc commands only if the shell is interactive (i.e., the prompt variable must be set).
if ($?prompt) then set commands, alias commands, etc. endif 5.3.2 Variable Modifiers
Except for
$?
5.3.2.1 Examples Using Pathname ModifiersThe table below shows the use of pathname modifiers on the following variable:
aa=(/progs/num.c /book/chap.ps)
5.3.2.2 Examples Using Quoting Modifiers
% 5.3.3 Predefined Shell VariablesVariables can be set in one of two ways, by assigning a value:
set or by simply turning them on:
set In the table below, variables that accept values are shown with the equal sign followed by the type of value they accept; the value is then described. (Note, however, that variables such as argv , cwd , or status are never explicitly assigned.) For variables that are turned on or off, the table describes what they do when set. The C shell automatically sets the variables argv , cwd , home , path , prompt , shell , status , term , and user . 5.3.4 Example .cshrc File
# PREDEFINED VARIABLES set path=(~ ~/bin /usr/ucb /bin /usr/bin . ) set mail=(/usr/mail/tom) if ($?prompt) then # settings for interactive use set echo set filec set noclobber ignoreeof set cdpath=(/usr/lib /usr/spool/uucp) # Now I can type cd macros # instead of cd /usr/lib/macros set fignore=.o # ignore object files for filec set history=100 savehist=25 set prompt='tom \!% ' # includes history number set time=3 # MY VARIABLES set man1="/usr/man/man1" # lets me do cd $man1, ls $man1 set a="[a-z]*" # lets me do vi $a set A="[A-Z]*" # or grep string $A # ALIASES alias c "clear; dirs" # use quotes to protect ; or | alias h "history|more" alias j jobs -l alias ls ls -sFC # redefine ls command alias del 'mv \!* ~/tmp_dir' # a safe alternative to rm endif 5.3.5 Environment Variables
The C shell maintains a set of Environment variables are assigned as follows:
setenv By convention, environment variable names are all uppercase. You can create your own environment variables, or you can use the predefined environment variables below. These environment variables have a corresponding C shell variable. When either one changes, the value is copied to the other:
Other environment variables include the following:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|