Arithmetic expansion

From LQWiki
Jump to navigation Jump to search

Arithmetic expansion is the process by which shells replace an arithmetical expression by its result. In bash, the format for arithmetical expansion is $((expression)).

The order of operations within the expression is determined using normal arithmetical rules for operator precedence. So, for example, 5*(2+3) means "add 2 and 3 together first and then multiply the result by 5". (answer = 25).