The let command performs arithmetic. ksh88 and Bash are restricted to integer arithmetic. ksh93 can do floatingpoint arithmetic as well. Both shells provide a way to substitute arithmetic values (for use as command arguments or in variables); base conversion is also possible:

Use the value of the enclosed arithmetic expression. 

Interpret integer
n in numeric base B.
For example, 
The shells use arithmetic operators from the C programming
language, in decreasing order of precedence. ksh88 does not support the ++
, 
,
unary +
, ?:
, comma, or **
operators. Early versions of ksh93 do not have **
.
Operator 
Description 

^{a} In
ksh93, the  

Autoincrement and autodecrement, both prefix and postfix. 

Unary plus and minus, logical negation and binary inversion (one's complement). 

Exponentiation.^{a} 

Multiplication; division; modulus (remainder). 

Addition; subtraction. 

Bitwise left shift; bitwise right shift. 

Less than; less than or equal to; greater than; greater than or equal to. 

Equality; inequality (both evaluated left to right). 

Bitwise AND. 

Bitwise exclusive OR. 

Bitwise OR. 

Logical AND (shortcircuit). 

Logical OR (shortcircuit). 

Inline conditional evaluation. 
 
 

Assignment. 
 

Sequential expression evaluation. 
ksh93 provides access to the standard set of mathematical functions. They are called using C function call syntax.
Name 
Function 
Name 
Function 


Absolute value 

Euclidean distance 

Arc cosine 

Integer part of floatingpoint number 

Arc sine 

Natural logarithm 

Arc tangent 

Exponentiation (x y) 

Arc tangent of two values 

Sine 

Cosine 

Hyperbolic sine 

Hyperbolic cosine 

Square root 

Exponential (e x) 

Tangent 

Floatingpoint remainder 

Hyperbolic tangent 
let "count=0" "i = i + 1" Assign i and count let "num % 2" Test for an even number (( percent >= 0 && percent <= 100 ))Test the range of a value
See the let entry in the later section "Builtin Commands (Bash and Korn Shells)" for more information and examples.
No credit card required