let builtin
The bash builtin that evaluates arithmetic given as arguments, as in let "total = a + b".
In more detail
It works like (( )) but each expression is a separate argument, so one with spaces must be quoted. Most scripts use (( )) instead because it needs no quoting. let is a bash feature, not POSIX.
Example
let "total = a + b"Related terms
- arithmetic expansion — Evaluating whole-number maths inside $(( )) and replacing it with the result; (( )) on its own evaluates without printing anything.
- integer arithmetic — Maths on whole numbers only, which is all bash can do itself: 7 / 2 gives 3, with the remainder dropped.
Taught in
- Arithmetic: Double Parentheses, let And bc — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation