1 00:00:01,530 --> 00:00:04,080 Arithmetic expansions in Shell. 2 00:00:04,110 --> 00:00:11,160 The shell allows arithmetic to be performed by an expansion, so this allows us to use the shell prompt 3 00:00:11,160 --> 00:00:12,480 as a calculator. 4 00:00:12,480 --> 00:00:21,000 So, for example, let's do this echo, and now we're going to do here braces, oops, braces here. 5 00:00:21,000 --> 00:00:24,420 And for example, two plus two. 6 00:00:24,750 --> 00:00:27,600 And as you can see here, we got an four. 7 00:00:27,720 --> 00:00:33,300 So arithmetic, exemptions, expansions, you can be used like this, for example. 8 00:00:33,300 --> 00:00:37,020 You will firstly, let's actually use our grommet. 9 00:00:37,770 --> 00:00:43,290 So you will use the expansion, the dollar sign. 10 00:00:43,290 --> 00:00:51,030 And after that, two braces here and you write your expression here expression. 11 00:00:55,520 --> 00:00:56,510 Here. 12 00:00:56,510 --> 00:01:01,040 Now use two curly braces again. 13 00:01:01,040 --> 00:01:03,260 And after that, that's it. 14 00:01:03,260 --> 00:01:09,050 So, of course, don't forget to write your echo command before then. 15 00:01:09,050 --> 00:01:13,820 So we here we have the just an empty space. 16 00:01:13,820 --> 00:01:20,840 So where expression is an arithmetic expression consisting of values and arithmetic operators. 17 00:01:20,840 --> 00:01:30,290 So arithmetic expression expansion supports only integers, whole numbers, no decimals, but can perform 18 00:01:30,290 --> 00:01:32,510 quite a number of different operations. 19 00:01:32,510 --> 00:01:41,390 So for example, it can be used for addition for subtraction, for multiplication, for division. 20 00:01:41,870 --> 00:01:50,240 But remember, since expansion supports only integer arithmetic, the result is going to be always, 21 00:01:50,360 --> 00:01:51,890 always. 22 00:01:53,300 --> 00:01:54,320 Integer. 23 00:01:54,350 --> 00:01:56,300 Integer. 24 00:01:56,330 --> 00:01:57,170 Output. 25 00:02:00,510 --> 00:02:07,230 And it also supports modulo which is which simply means reminder. 26 00:02:07,230 --> 00:02:12,030 And we also have exponentiation, which is two here. 27 00:02:12,030 --> 00:02:16,920 So we also have an exponentiation here. 28 00:02:17,720 --> 00:02:20,330 So spaces are not significant in arithmetic. 29 00:02:20,330 --> 00:02:23,690 Operations and expressions can be nested. 30 00:02:23,720 --> 00:02:27,690 For example, here, let's do another example like this. 31 00:02:27,710 --> 00:02:30,440 So for example, let's write Echo. 32 00:02:31,860 --> 00:02:32,220 Here. 33 00:02:35,800 --> 00:02:38,440 So we will write the nested expression right here. 34 00:02:39,270 --> 00:02:43,140 And after that you call braces again after dollar sign. 35 00:02:44,160 --> 00:02:46,950 And now five multiplication two. 36 00:02:47,490 --> 00:02:49,050 Not this isn't a multiplication. 37 00:02:49,050 --> 00:02:50,910 Actually, it's exponentiation. 38 00:02:50,910 --> 00:02:55,080 And after that we will use that three. 39 00:02:55,260 --> 00:02:57,290 And here, let's see the results here. 40 00:02:57,300 --> 00:02:59,340 So single parentheses. 41 00:02:59,340 --> 00:03:00,720 This is our results here. 42 00:03:00,720 --> 00:03:06,990 So a single parentheses may be used to group a multiple subexpressions. 43 00:03:06,990 --> 00:03:13,770 With this technique, you can rewrite the previous example and get the same result using the single 44 00:03:13,770 --> 00:03:16,110 expression instead of instead of two. 45 00:03:26,500 --> 00:03:29,500 And we can also write the strings and mix it together. 46 00:03:29,500 --> 00:03:33,160 So Echo, for example, five divided. 47 00:03:34,900 --> 00:03:38,620 Divided by two equals. 48 00:03:39,490 --> 00:03:42,870 And after that, we will enter our division here. 49 00:03:42,880 --> 00:03:52,450 So five divided by two and here and as you can see here, five divided by two equals two. 50 00:03:52,810 --> 00:03:57,460 Yeah, that's actually not a Yeah, that's actually true. 51 00:03:57,460 --> 00:04:03,720 But and I said earlier that this expressions in echo. 52 00:04:05,670 --> 00:04:11,610 Supports only integer arithmetic and the result is going to be integers.