The Korn shell's let command performs integer arithmetic. The Korn shell provides a way to substitute integer values (for use as command arguments or in variables); base conversion is also possible:
$(( |
Use the value of the enclosed arithmetic expression. |
|
Interpret integer |
The Korn shell uses arithmetic operators from the C programming language; they are listed below in decreasing order of precedence:
- |
Unary minus. |
! ~ |
Logical negation; binary inversion (one's complement). |
* / % |
Multiplication; division; modulus (remainder). |
+ - |
Addition; subtraction. |
<< >> |
Bitwise left shift; bitwise right shift. |
<= >= |
Less than or equal to; greater than or equal to. |
< > |
Less than; greater than. |
== != |
Equality; inequality (both evaluated left to right). |
& |
Bitwise AND. |
^ |
Bitwise exclusive OR. |
| |
Bitwise OR. |
&& |
Logical AND. |
|| |
Logical OR. |
*= /= %= |
Assignment. |
= += -= |
|
<<= >>= |
|
&= ^= |= |
|
See the let command for more information and examples.
let "count=0" "i = i + 1" Assigni
andcount
. let "num % 2" Test for an even number. (( percent >= 0 && percent <= 100 )) Test the range of a value.