let evaluates each arithmetic expression from left to right, with normal algebraic precedence (multiplication before addition, for example). let uses long integer arithmetic with no checks for overflow. No output is generated; the exit status is 0 if the last expression argument has a nonzero value, and 1 otherwise.
let "expression"
((expression))
$((expression))
Expressions consist of named variables, numeric constants, and operators. Characters in the names of named variables must come from thePOSIX portable character set.
Examples of the three forms of the let command are as follows:
let a=7
echo $a
produces: 7
echo $((a=7*9))
produces:
63
((a=3*4))
echo $a
produces: 12
let is a built-in shell command.
See Localization for more information.
POSIX.2. let and ((expression)) are extensions to the POSIX.2 standard. The POSIX.2 portable facility for arithmetic expression evaluation is $((expression)). See Arithmetic substitution for more information.
The (( )) syntax only works if the set –o korn option is in effect.
expr, sh, test