The (( Operator
Learn how the let command and the (( operator work in detail.
We'll cover the following
Bash performs integer arithmetic in math context.
The syntax of math context resembles the C language. The idea behind it is to make Bash easier to learn for programmers who have experience with the C language. Most users of the first Unix versions knew C.
Let’s suppose we want to store a result of adding two numbers in a variable. We need to declare it using the -i
attribute and assign a value in the declaration. Here is an example:
declare -i var=12+7
Run the commands discussed in this lesson in the terminal below.
Get hands-on with 1200+ tech skills courses.