5.3 VariablesThis section 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 if ($?prompt) then set commands, alias commands, etc. endif 5.3.2 Variable Modifiers
Except for
5.3.2.1 Examples using pathname modifiersThis table shows the use of pathname modifiers on the following variable: set 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 var =value or by simply turning them on: set var In the following table, variables that accept values are shown with the equals sign followed by the type of value they accept; the value is then described. (Note, however, that variables such as 5.3.4 Example .cshrc File# PREDEFINED VARIABLES set path=(~ ~/bin /usr/ucb /bin /usr/bin . ) set mail=(/var/mail/tom) if ($?prompt) then # Settings for interactive use set echo set filec set noclobber ignoreeof set cdpath=(/usr/lib /var/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 VariablesThe C shell maintains a set of environment variables , which are distinct from shell variables and aren't really part of the C shell. Shell variables are meaningful only within the current shell, but environment variables are automatically exported, making them available globally. For example, C shell variables are accessible only to a particular script in which they're defined, whereas environment variables can be used by any shell scripts, mail utilities, or editors you might invoke. Environment variables are assigned as follows: setenv VAR value By convention, environment variable names are all uppercase. You can create your own environment variables, or you can use the following predefined environment variables. These environment variables have a corresponding C shell variable:
Other environment variables include the following:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|