Arithmetic Expressions

The let command performs arithmetic. ksh88 and Bash are restricted to integer arithmetic. ksh93 can do floating-point 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:

$(( expr ))

Use the value of the enclosed arithmetic expression.

B # n

Interpret integer n in numeric base B. For example, 8#100 specifies the octal equivalent of decimal 64.

Get Unix in a Nutshell, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.