Arithmetic expansions in Shell.
The shell allows arithmetic to be performed by an expansion, so this allows us to use the shell prompt
as a calculator.
So, for example, let's do this echo, and now we're going to do here braces, oops, braces here.
And for example, two plus two.
And as you can see here, we got an four.
So arithmetic, exemptions, expansions, you can be used like this, for example.
You will firstly, let's actually use our grommet.
So you will use the expansion, the dollar sign.
And after that, two braces here and you write your expression here expression.
Here.
Now use two curly braces again.
And after that, that's it.
So, of course, don't forget to write your echo command before then.
So we here we have the just an empty space.
So where expression is an arithmetic expression consisting of values and arithmetic operators.
So arithmetic expression expansion supports only integers, whole numbers, no decimals, but can perform
quite a number of different operations.
So for example, it can be used for addition for subtraction, for multiplication, for division.
But remember, since expansion supports only integer arithmetic, the result is going to be always,
always.
Integer.
Output.
And it also supports modulo which is which simply means reminder.
And we also have exponentiation, which is two here.
So we also have an exponentiation here.
So spaces are not significant in arithmetic.
Operations and expressions can be nested.
For example, here, let's do another example like this.
So for example, let's write Echo.
Here.
So we will write the nested expression right here.
And after that you call braces again after dollar sign.
And now five multiplication two.
Not this isn't a multiplication.
Actually, it's exponentiation.
And after that we will use that three.
And here, let's see the results here.
So single parentheses.
This is our results here.
So a single parentheses may be used to group a multiple subexpressions.
With this technique, you can rewrite the previous example and get the same result using the single
expression instead of instead of two.
And we can also write the strings and mix it together.
So Echo, for example, five divided.
Divided by two equals.
And after that, we will enter our division here.
So five divided by two and here and as you can see here, five divided by two equals two.
Yeah, that's actually not a Yeah, that's actually true.
But and I said earlier that this expressions in echo.
Supports only integer arithmetic and the result is going to be integers.