Variables
This subsection describes the following:
Variable substitution
Variable modifiers
Predefined shell variables
Formatting for the
promptvariableSample .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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access