UNIX for OpenVMS Users, Third Edition

We have seen that the C shell set command associates a value to a variable and that such values may be integers or text (e.g., set a = 1 or set a = "test"). The ksh and bash shells surround an arithmetic operation with double parentheses: ((a = 1)). Perl variable assignment statements closely model the syntax used in the C language (e.g., $x = 5 and $y++). OpenVMS uses = to equate a variable to an integer value and := or =... to equate a variable to a string value. The OpenVMS user can perform mathematical operations on either string or integer values. The UNIX C shell permits only mathematical operations on integer variables, whereas Perl and the Korn and bash shells permit arithmetic on string variables if the value of the variable equates to an integer. The C shell @ metacharacter equates a variable name to the result of a mathematical operation using integer variables. Table 10.6 lists mathematical operators used by the shells and Perl.
| C Shell Operator | Bash and Korn Shell Operator | Perl | OpenVMS Equivalent | UNIX Meaning |
|---|---|---|---|---|
| Integers | ||||
| + | + | + | + | Add |
| - | - | - | - | Subtract |
| * | * | * | * | Multiply |
| / | / | // | Divide | |
| ++ | ++ | ++ | Increment by 1 | |
| -- | -- | -- | Decrement by 1 | |
| % | % | % | Modulo | |
| Bits | ||||
| >> | >> | >> |