Variables
This subsection describes the following:
Variable substitution
Variable modifiers
Predefined shell variables
Formatting for the
prompt
variableSample .cshrc file
Environment variables
Variable substitution
In
the following substitutions, braces ({ }
) are
optional, except when needed to separate a variable name from
following characters that would otherwise be considered part of the
name:
Variable |
Description |
---|---|
|
The value of variable |
|
Select word or words in position |
|
The number of words in |
|
The number of arguments. |
|
Name of the program. |
|
Individual arguments on command line (positional parameters); 1≤n≤9. |
|
Same as
|
|
All arguments on command line. |
|
Same as |
|
The last argument. |
|
Return 1 if |
|
Process number of current shell; useful as part of a filename for creating temporary files with unique names. |
|
Return 1 if |
|
Return 1 if input filename is known, 0 if not. |
Examples
Sort the third through last arguments and save the output in a file whose name is unique to this process:
sort $argv[3-] > tmp.$$
Process ...
Get Mac OS X in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.