May 2000
Beginner
761 pages
18h 20m
English
There is not really a need to do math problems in a shell script, but sometimes arithmetic is necessary, e.g., to increment or decrement a loop counter. The TC shell supports integer arithmetic only. The @ symbol is used to assign the results of calculations to numeric variables.
The following operators in Table 11.1 are used to perform integer arithmetic operations. They are the same operators found in the C programming language. See Table 11.6 on page 629 for operator precedence. Also borrowed from the C language are shortcut assignment operators, shown in Table 11.2.
| Function | Operator |
|---|---|
| Addition | + |
| Subtraction | – |
| Division | / |
| Multiplication | * |
| Modulus | % |
| Left shift ... |
Read now
Unlock full access