1 00:00:01,430 --> 00:00:02,600 Hello everyone. 2 00:00:02,600 --> 00:00:07,490 In this demo, I'm going to show you some examples of bash scripting. 3 00:00:08,090 --> 00:00:11,150 Let's start with the first example, the user input. 4 00:00:11,150 --> 00:00:13,540 So I'm going to start, as you can see over here. 5 00:00:13,550 --> 00:00:14,960 Here are some examples. 6 00:00:14,960 --> 00:00:18,530 So I'm going to start with the first example here. 7 00:00:18,530 --> 00:00:25,040 The user input, the strings that is So strings go. 8 00:00:25,040 --> 00:00:27,170 Here we see what is the script over here? 9 00:00:27,170 --> 00:00:30,260 As we can see here, this is the shebang. 10 00:00:30,290 --> 00:00:34,640 The first line and here is the comment, I think nothing new over here. 11 00:00:34,640 --> 00:00:39,260 So this is says that this is the this script shows your first name. 12 00:00:39,270 --> 00:00:39,920 Also. 13 00:00:39,920 --> 00:00:48,770 Maybe you can type here also your first name and last name. 14 00:00:49,130 --> 00:00:50,060 Perfect. 15 00:00:50,090 --> 00:00:54,950 Next, as we can see over here, echo the echo command. 16 00:00:54,950 --> 00:01:01,920 We're going to all in this line just we are going to type or we're going to show just this message. 17 00:01:01,920 --> 00:01:04,140 Hello, may I know your first name? 18 00:01:04,140 --> 00:01:05,760 Then we can see here. 19 00:01:05,760 --> 00:01:06,930 This is the command read. 20 00:01:06,930 --> 00:01:14,100 So this command is going the read command is going to transfer the control from the running script, 21 00:01:14,100 --> 00:01:15,390 which is the script. 22 00:01:16,110 --> 00:01:18,450 To the user in order. 23 00:01:18,480 --> 00:01:19,070 Why? 24 00:01:19,110 --> 00:01:25,380 To let the user to type the first name and the last name, then store whatever the user enters. 25 00:01:25,380 --> 00:01:27,030 So we're going to store. 26 00:01:27,210 --> 00:01:32,500 For example, if the user entered, the first name is John, so he's going to store. 27 00:01:32,830 --> 00:01:38,880 Store or save the the name over here and this variable. 28 00:01:40,000 --> 00:01:40,990 A first name. 29 00:01:40,990 --> 00:01:44,180 And there is also a second message over here. 30 00:01:44,200 --> 00:01:51,610 We asking the user to enter the last name and we're going to save whatever the user is going to enter 31 00:01:51,610 --> 00:01:54,070 and the last name variable. 32 00:01:54,430 --> 00:01:58,380 And here we're going to show a message after that. 33 00:01:58,390 --> 00:01:59,890 So thank you. 34 00:02:00,040 --> 00:02:02,850 Then as we can see, this is the dollar sign. 35 00:02:02,860 --> 00:02:13,510 Why we're using the dollar sign before the variables, because we would like to show what the user entered. 36 00:02:13,600 --> 00:02:15,670 So we're going to show the value. 37 00:02:15,700 --> 00:02:19,600 We're not going to show the name first name if we're not going to put the dollar sign. 38 00:02:19,600 --> 00:02:25,870 So the system is going to show first name and last name. 39 00:02:25,870 --> 00:02:33,550 So the reason we put the dollar sign, because we would like to print the value of the variable. 40 00:02:34,090 --> 00:02:34,600 Perfect. 41 00:02:34,600 --> 00:02:35,400 So far, so good. 42 00:02:35,410 --> 00:02:37,540 Now let's run this. 43 00:02:37,540 --> 00:02:46,000 So control, so shift x colon X, then the bank or the exclamation mark hit Enter. 44 00:02:46,360 --> 00:02:50,590 Now I'm going to run this script. 45 00:02:51,760 --> 00:02:52,990 Strings. 46 00:02:55,320 --> 00:02:57,420 That is hit enter. 47 00:02:57,420 --> 00:02:59,190 So as you can see over here. 48 00:02:59,190 --> 00:02:59,640 Hello. 49 00:02:59,670 --> 00:03:01,560 May I know your first name? 50 00:03:01,920 --> 00:03:02,550 Say, John. 51 00:03:05,130 --> 00:03:08,450 Then hit enter will ask me the second question. 52 00:03:08,460 --> 00:03:09,900 Say your last name. 53 00:03:09,900 --> 00:03:14,340 You know, just I'm going to just type uppercase L hit enter. 54 00:03:14,340 --> 00:03:16,530 As we can see here, this is the last message. 55 00:03:16,530 --> 00:03:17,910 Thank you, John. 56 00:03:17,910 --> 00:03:20,570 L So far, so good. 57 00:03:20,580 --> 00:03:21,000 Perfect. 58 00:03:21,090 --> 00:03:23,340 Let's move on right now to the second example. 59 00:03:23,340 --> 00:03:28,440 So the second example that I would like to show you is the sum. 60 00:03:28,440 --> 00:03:32,160 So sum that is H hit enter. 61 00:03:32,160 --> 00:03:34,920 So as we can hear, this is the shebang line. 62 00:03:35,040 --> 00:03:35,880 This is the comment. 63 00:03:35,880 --> 00:03:38,250 So this script shows the sum of the three numbers. 64 00:03:38,250 --> 00:03:45,060 So as we can see here, here's the parentheses because we would like to do some between three numbers 65 00:03:45,450 --> 00:03:57,900 and we put so sum here is the variable then equal 20 plus 30 plus 40, and we put all of them inside 66 00:03:57,900 --> 00:04:04,930 double parentheses, as you can see here, two parentheses at the beginning and at the end, two parentheses. 67 00:04:04,930 --> 00:04:07,360 Then here we're going to show a message echo. 68 00:04:07,390 --> 00:04:11,020 The numbers are 20 plus, 30 plus 40. 69 00:04:11,020 --> 00:04:15,760 And the second or the last line here or the third line. 70 00:04:15,790 --> 00:04:22,450 The last line here is the result is and as I mentioned in the previous script, we need to. 71 00:04:23,640 --> 00:04:27,990 Type the dollar sign and then the name of the variable. 72 00:04:27,990 --> 00:04:29,780 So this is the variable here. 73 00:04:29,790 --> 00:04:37,170 So we need to do that in order to show what is the value of that variable. 74 00:04:37,380 --> 00:04:38,250 Perfect. 75 00:04:38,280 --> 00:04:40,560 Just run the script. 76 00:04:40,560 --> 00:04:44,660 So some that search hit enter. 77 00:04:44,670 --> 00:04:49,020 As we can see here, the numbers are 20 plus, 30 plus 40. 78 00:04:49,020 --> 00:04:50,310 And here is the return. 79 00:04:50,340 --> 00:04:54,600 So here is the sum of these three numbers. 80 00:04:54,630 --> 00:04:55,800 You can do the same thing. 81 00:04:55,800 --> 00:05:12,480 But as I mentioned before, since I do cat home slash John and slash dash bash says hit enter. 82 00:05:12,480 --> 00:05:15,210 As I said that because I added this line over here. 83 00:05:15,210 --> 00:05:21,060 This is the line and this file is the configuration file. 84 00:05:21,060 --> 00:05:30,370 So I don't need to type the dot slash or the bash before the name of the script file. 85 00:05:31,330 --> 00:05:31,720 Okay. 86 00:05:31,720 --> 00:05:32,760 Now let's move on. 87 00:05:32,770 --> 00:05:34,930 Let's move on to the third example. 88 00:05:34,930 --> 00:05:37,840 So the third example here is the length. 89 00:05:37,930 --> 00:05:43,690 So the length that is H So what is the purpose of this? 90 00:05:43,720 --> 00:05:45,430 This is the shebang line. 91 00:05:45,550 --> 00:05:49,930 So here I would like to show a message to the user. 92 00:05:49,960 --> 00:05:53,710 Could you please type your name and your age? 93 00:05:53,950 --> 00:05:57,100 And we have the read command. 94 00:05:57,100 --> 00:06:02,860 And as I mentioned before, the read command is going to transfer the control from the running script 95 00:06:02,860 --> 00:06:03,940 to the user. 96 00:06:04,690 --> 00:06:12,040 If you guys remember when we showed that message and we asked the user to enter the value, So so the 97 00:06:12,400 --> 00:06:20,440 so is going to lead the user to type the the name, then the age, then we're going to store whatever 98 00:06:20,440 --> 00:06:26,400 the user entered in this variable in the length variable. 99 00:06:28,200 --> 00:06:32,760 Then what we're going to do here, we see the message over here is the last night. 100 00:06:32,760 --> 00:06:34,470 So the length of this string. 101 00:06:34,470 --> 00:06:42,780 So the purpose of this script, I would like to show what is the length of the variable that the user 102 00:06:42,780 --> 00:06:44,100 is going to type. 103 00:06:44,460 --> 00:06:48,960 And I know it's kind new for you guys. 104 00:06:48,960 --> 00:06:54,570 So here is the dollar sign, the reason of the dollar sign because we would like to get the value. 105 00:06:54,600 --> 00:06:58,050 Then we have here what we have. 106 00:06:58,050 --> 00:07:04,500 We have the braces, then hash length, then we close the braces. 107 00:07:04,500 --> 00:07:11,070 So we it's really important that we know the structure because this is the syntax structure of the bash 108 00:07:11,070 --> 00:07:11,640 scripting. 109 00:07:11,640 --> 00:07:15,270 So in order to get a good outcome, we need to know the structure. 110 00:07:15,270 --> 00:07:16,620 So dollar. 111 00:07:16,650 --> 00:07:19,680 Then we open the parenthesis and we close it. 112 00:07:19,680 --> 00:07:24,420 Then inside that hash length, let's run the script. 113 00:07:24,810 --> 00:07:28,720 So length that is h So what's your name? 114 00:07:28,870 --> 00:07:29,860 My name is John. 115 00:07:29,860 --> 00:07:43,420 And say I'll say here, my name is John and for example, not 50, 30 years old, hit enter. 116 00:07:43,420 --> 00:07:45,580 As we can see over here, this is the message. 117 00:07:45,580 --> 00:07:49,840 The length of this string is 37. 118 00:07:50,020 --> 00:07:55,390 So this is the length and also is going to consider the spaces. 119 00:07:55,390 --> 00:08:01,120 So from here to here, if you're going to count them, they are 37. 120 00:08:02,800 --> 00:08:04,840 Okay, So now let's move on. 121 00:08:04,840 --> 00:08:11,440 There is a file also I would like to show you before I'm going to explain the fourth example, the if 122 00:08:11,440 --> 00:08:12,250 else. 123 00:08:12,970 --> 00:08:13,420 Okay. 124 00:08:13,420 --> 00:08:20,920 So cat slash home slash and I save that file under the directory. 125 00:08:20,920 --> 00:08:25,270 That is examples and operators hit enter. 126 00:08:25,270 --> 00:08:29,650 So this is the syntax that we're going to use in the bash scripting. 127 00:08:29,650 --> 00:08:30,730 So here is the samples. 128 00:08:30,730 --> 00:08:32,740 We're going to use those, the syntax. 129 00:08:32,740 --> 00:08:36,850 So the dash EQ, it means that equal, equal. 130 00:08:36,850 --> 00:08:43,000 So it means equal if we'd like to compare between values, for example, if I would like to compare 131 00:08:43,000 --> 00:08:48,430 between two values, the value one it's two and value three. 132 00:08:48,460 --> 00:08:52,810 So value one is two and value two is three. 133 00:08:53,200 --> 00:08:54,070 Are they equal? 134 00:08:54,070 --> 00:08:56,950 Not they are not equal. 135 00:08:56,950 --> 00:09:01,690 And this is the another syntax that we're going to use in the in this, the bash script. 136 00:09:01,690 --> 00:09:12,970 So dash and E, it means not equal and here is dash get greater than dash G so it's greater than or 137 00:09:12,970 --> 00:09:22,060 equal and dash lt is less than or dash la so is less than or equal. 138 00:09:23,680 --> 00:09:25,960 Okay, now let's run the script. 139 00:09:25,960 --> 00:09:34,920 So the script is f ls f dash ls h enter. 140 00:09:35,700 --> 00:09:37,920 So as we can see over here. 141 00:09:38,310 --> 00:09:45,600 So the purpose of this script, we would like to ask the user, so to ask the user a question, what 142 00:09:45,600 --> 00:09:48,090 is the root user uid? 143 00:09:49,300 --> 00:09:52,960 The Uid, so you know that every user has a Uid. 144 00:09:53,680 --> 00:09:56,380 Then this is the read command. 145 00:09:56,380 --> 00:09:59,560 So it's going to transfer. 146 00:10:00,450 --> 00:10:05,490 As I mentioned before, is going to transfer the controller from the running machine running script 147 00:10:05,490 --> 00:10:07,950 to the user in order to type. 148 00:10:10,040 --> 00:10:12,200 For example, type whatever string or ID. 149 00:10:12,710 --> 00:10:19,880 And here is a comment said the Uid of root user is zero and here we have the. 150 00:10:20,990 --> 00:10:26,660 So as I mentioned before, we need to know the structure in order to understand any programming language 151 00:10:26,660 --> 00:10:29,660 or even the bash scripting, you need to know the structure. 152 00:10:29,660 --> 00:10:31,880 So for if else is a condition. 153 00:10:32,180 --> 00:10:34,070 So we type if. 154 00:10:35,030 --> 00:10:36,440 Then else. 155 00:10:36,440 --> 00:10:40,010 Then we close the F, so F, then we close this f. 156 00:10:40,220 --> 00:10:43,580 So between here, as you can see over here, this is the. 157 00:10:44,940 --> 00:10:46,620 The brackets. 158 00:10:46,620 --> 00:10:51,020 So between the brackets, we need to leave spaces at the beginning and the end. 159 00:10:51,030 --> 00:10:52,750 And here the value is zero. 160 00:10:52,770 --> 00:10:54,330 So this one is what? 161 00:10:54,840 --> 00:10:55,860 Equal. 162 00:10:56,310 --> 00:10:59,820 So if this value equal to this value. 163 00:11:00,150 --> 00:11:01,350 So the dollar sign. 164 00:11:01,350 --> 00:11:08,280 And we need also to put in between the quotation mark because we're going to compare these two values. 165 00:11:08,280 --> 00:11:11,400 So I'm going to compare this value with this value. 166 00:11:11,760 --> 00:11:13,320 If they are equal. 167 00:11:13,320 --> 00:11:18,690 So if the first value is equal to the second value, then. 168 00:11:19,890 --> 00:11:21,210 Print this message. 169 00:11:22,440 --> 00:11:27,810 If this value is not equal to this value, then we're going to skip this. 170 00:11:27,840 --> 00:11:29,100 We're not going to do anything. 171 00:11:29,100 --> 00:11:31,430 So we're not going to print this line. 172 00:11:31,440 --> 00:11:33,300 We're going to go to the else. 173 00:11:34,290 --> 00:11:37,550 So if this is true, then we're going to print this one. 174 00:11:37,560 --> 00:11:44,550 If this is false, this line is false, then we're going to print whatever is under the else. 175 00:11:44,550 --> 00:11:50,820 So if you are not the system administrator, let's run this script. 176 00:11:51,510 --> 00:11:56,250 So if else that is h hit enter. 177 00:11:56,250 --> 00:12:03,870 So what is the root user uid if I hit zero, you are the system administrator. 178 00:12:04,020 --> 00:12:08,160 Let me show you the content of this script. 179 00:12:08,820 --> 00:12:10,920 Shebang line doesn't matter here. 180 00:12:10,920 --> 00:12:12,210 So this is a question. 181 00:12:12,360 --> 00:12:13,320 Perfect. 182 00:12:13,590 --> 00:12:21,130 We give the user and we lead the user to enter the value we saved zero in this variable. 183 00:12:21,130 --> 00:12:23,710 So the value of ID is zero. 184 00:12:24,370 --> 00:12:25,720 Then it's a comma. 185 00:12:25,930 --> 00:12:26,740 Here is the comment. 186 00:12:26,740 --> 00:12:27,460 It doesn't matter. 187 00:12:27,460 --> 00:12:28,300 So we're going to take. 188 00:12:28,300 --> 00:12:36,880 So if this value is zero, it's already zero equal to this value, which here is the value here. 189 00:12:36,880 --> 00:12:44,110 So the dollar sign ID, then print this one and this is what the outcome of the script. 190 00:12:44,110 --> 00:12:51,220 You are the system administrator and we get this message if this one is not true. 191 00:12:51,840 --> 00:12:52,530 False. 192 00:12:52,530 --> 00:12:54,120 We're going to print this message. 193 00:12:54,900 --> 00:12:56,140 So far, so good. 194 00:12:56,160 --> 00:12:56,730 Perfect. 195 00:12:56,760 --> 00:13:01,020 Now let's move on to the fifth example. 196 00:13:01,500 --> 00:13:03,040 The while loop. 197 00:13:03,060 --> 00:13:06,210 So for a while loop. 198 00:13:07,270 --> 00:13:08,140 That is it. 199 00:13:08,410 --> 00:13:09,890 So this is a loop. 200 00:13:09,910 --> 00:13:16,930 If you hear about loop, it means that it's going to is like there is iteration that is going to go 201 00:13:16,930 --> 00:13:20,500 over values like more than once. 202 00:13:20,530 --> 00:13:20,770 Okay. 203 00:13:20,770 --> 00:13:21,490 Let me explain. 204 00:13:21,490 --> 00:13:22,630 What what do you mean by that? 205 00:13:22,630 --> 00:13:26,260 So here is the this script prints the numbers from 1 to 10. 206 00:13:26,260 --> 00:13:28,690 So this is the main objective of this script. 207 00:13:28,690 --> 00:13:30,700 And this is another comment here. 208 00:13:30,700 --> 00:13:36,610 This is the initial value, the initial value for the X, We assign a value to this variable. 209 00:13:36,610 --> 00:13:44,170 So the variable is X, So x equal one, it means that I'm going to assign number one, the value to 210 00:13:44,170 --> 00:13:45,190 this variable. 211 00:13:46,030 --> 00:13:48,190 Next here is a comment. 212 00:13:48,190 --> 00:13:49,690 So this is the while loop. 213 00:13:50,320 --> 00:13:54,280 So the while loop here we have the while do then done. 214 00:13:54,640 --> 00:14:01,390 So if the while if this line is true, then do this line. 215 00:14:01,390 --> 00:14:04,180 It means you go inside and print this line. 216 00:14:04,210 --> 00:14:13,550 Then if it gets notice here we have the parentheses x and c x plus plus and between double parentheses 217 00:14:13,580 --> 00:14:15,800 y we need what does it mean? 218 00:14:15,800 --> 00:14:19,790 That x plus plus it means that is going to increase the value. 219 00:14:19,790 --> 00:14:22,130 So the initial value, it's one. 220 00:14:22,870 --> 00:14:25,300 So we're going to so we're going to run the script. 221 00:14:25,300 --> 00:14:28,210 So it's going to run line by line. 222 00:14:28,210 --> 00:14:29,050 We'll ignore. 223 00:14:29,050 --> 00:14:30,130 So this is the shebang. 224 00:14:30,160 --> 00:14:31,930 Ignore this line, ignore this line. 225 00:14:31,960 --> 00:14:35,410 Then we'll assign one to the X, then ignore this line. 226 00:14:35,410 --> 00:14:37,720 Then we'll go to the Y line. 227 00:14:37,720 --> 00:14:40,540 And we have here we have the brackets. 228 00:14:40,540 --> 00:14:45,880 So the brackets here, as I said, that you have to leave a space at the beginning and end. 229 00:14:45,880 --> 00:14:51,370 And then as I said before, we need to use the dollar sign in order to get the value. 230 00:14:51,400 --> 00:14:53,170 We don't want to use the variable. 231 00:14:53,170 --> 00:14:54,800 We don't I don't need the x Y. 232 00:14:54,800 --> 00:14:57,520 I need to I need to compare X to ten. 233 00:14:57,520 --> 00:15:01,320 I need to compare the value of x, which is 1 to 10. 234 00:15:01,330 --> 00:15:05,260 So he said if one is less. 235 00:15:06,240 --> 00:15:07,380 Then ten. 236 00:15:08,230 --> 00:15:09,400 Then do this line. 237 00:15:09,400 --> 00:15:13,150 So the number is and we're going to print the number. 238 00:15:13,720 --> 00:15:14,980 So here is one. 239 00:15:16,130 --> 00:15:17,300 One is less than ten. 240 00:15:17,330 --> 00:15:17,960 Good. 241 00:15:17,990 --> 00:15:18,610 True. 242 00:15:18,620 --> 00:15:20,120 So the number is one. 243 00:15:20,150 --> 00:15:21,890 Then we're going to increase it. 244 00:15:21,890 --> 00:15:27,010 So we're going to go back again here to the while line here. 245 00:15:27,020 --> 00:15:28,280 So this time. 246 00:15:28,280 --> 00:15:31,430 So after we increase the number to two, two is less than ten. 247 00:15:31,460 --> 00:15:31,880 Yep. 248 00:15:31,880 --> 00:15:32,540 Good. 249 00:15:33,410 --> 00:15:34,850 Then we're going to increase. 250 00:15:34,850 --> 00:15:39,590 We're going to print two, then increase the number 2 to 3 and go up again. 251 00:15:39,830 --> 00:15:45,800 And here is three less perfect print three, then increase it to four. 252 00:15:45,800 --> 00:15:53,750 We're going to do it till we're going to reach what, two number ten. 253 00:15:54,080 --> 00:15:59,510 So if we're going to let me run the script so we can get an idea about it. 254 00:15:59,510 --> 00:15:59,830 Okay. 255 00:15:59,840 --> 00:16:06,980 While loop, while dash loop that is which enter as we can see. 256 00:16:07,010 --> 00:16:07,250 Three. 257 00:16:07,250 --> 00:16:10,070 So cat while loop. 258 00:16:13,680 --> 00:16:14,190 Ginger. 259 00:16:14,640 --> 00:16:20,400 So the initial value here, we compare this 1 to 10, perfect is true. 260 00:16:20,400 --> 00:16:21,620 So we're going to print this one. 261 00:16:21,630 --> 00:16:28,230 So the number is one, then we increase two, two two is less perfect. 262 00:16:28,230 --> 00:16:30,930 We're going to print two, then increase it to three. 263 00:16:30,930 --> 00:16:32,370 We're going to do it till ten. 264 00:16:32,490 --> 00:16:39,480 Once we're going to increase it to 11, the last value here, we're going to go over here and is it 265 00:16:39,480 --> 00:16:41,100 11 less than ten? 266 00:16:41,130 --> 00:16:42,780 No, false. 267 00:16:42,780 --> 00:16:47,970 So we will jump from here to done. 268 00:16:48,360 --> 00:16:49,890 We're not going to do. 269 00:16:51,040 --> 00:16:55,660 This two lines anymore because we 11 is less than ten. 270 00:16:56,650 --> 00:16:57,310 Perfect. 271 00:16:57,310 --> 00:16:58,140 So far, so good. 272 00:16:58,150 --> 00:17:00,640 Okay, let's do the sixth example. 273 00:17:02,620 --> 00:17:05,829 And this example, it's the for loop. 274 00:17:06,369 --> 00:17:08,380 So it's the same concept. 275 00:17:11,140 --> 00:17:12,430 It's a different structure. 276 00:17:13,000 --> 00:17:14,770 Both of them are loops. 277 00:17:15,130 --> 00:17:19,300 The while has different syntax and therefore has different syntax. 278 00:17:19,300 --> 00:17:23,980 So here is the same thing printing from 1 to 10 for loop. 279 00:17:24,010 --> 00:17:26,589 So here, let's see the syntax of the for loop. 280 00:17:26,589 --> 00:17:29,080 So we have for do then done. 281 00:17:30,230 --> 00:17:39,620 So if let's go for here let's go to to this line for then we have the double parenthesis. 282 00:17:40,410 --> 00:17:41,730 We need to put the condition. 283 00:17:41,730 --> 00:17:48,330 So the difference here, if you guys notice in the while we assign the initial value before the Y. 284 00:17:49,580 --> 00:17:50,330 Command. 285 00:17:50,600 --> 00:17:58,010 Although I lie here for the four, we have three things we need to do it inside the double parenthesis. 286 00:17:58,130 --> 00:18:04,070 We have the initial value, then semicolon, then we have the condition, then semicolon. 287 00:18:04,070 --> 00:18:07,670 Then we have the increment that we're going to increase the number. 288 00:18:07,670 --> 00:18:11,420 So the initial value for x is one, then semicolon. 289 00:18:11,870 --> 00:18:13,790 Then we're going to compare X. 290 00:18:13,910 --> 00:18:15,500 Is it equal? 291 00:18:16,010 --> 00:18:21,410 Is less or equal than ten, then semicolon, then we increase. 292 00:18:21,680 --> 00:18:22,520 Then here. 293 00:18:22,520 --> 00:18:26,510 If it's true, if this line is true, then we print the number last. 294 00:18:26,810 --> 00:18:28,340 Let's do a demo here. 295 00:18:28,850 --> 00:18:30,500 We're going to run the script. 296 00:18:31,820 --> 00:18:36,560 Hit enter cat for loop hit enter here. 297 00:18:36,860 --> 00:18:40,580 So these three lines, we just ignored them. 298 00:18:40,580 --> 00:18:43,070 This is the shebang line. 299 00:18:43,070 --> 00:18:43,790 Comment. 300 00:18:43,790 --> 00:18:44,540 Comment. 301 00:18:44,540 --> 00:18:46,850 So here is the initial value one. 302 00:18:47,710 --> 00:18:50,260 X, It's one here. 303 00:18:50,260 --> 00:18:54,790 The value less than or less than or equal to ten. 304 00:18:55,540 --> 00:18:56,290 True. 305 00:18:57,010 --> 00:19:04,720 Then we're going to increase the value and then print this message. 306 00:19:04,720 --> 00:19:07,480 The number is one and we're going to do that. 307 00:19:07,720 --> 00:19:09,250 We're going to print the last value. 308 00:19:09,250 --> 00:19:11,290 So we're going to reach here to 11. 309 00:19:13,030 --> 00:19:16,210 So here is so when are you going to be over here? 310 00:19:16,210 --> 00:19:18,340 If it's here, the condition is false. 311 00:19:18,340 --> 00:19:19,690 It will jump. 312 00:19:19,780 --> 00:19:26,740 It's not going to look to these two commands will jump to the to the last line, to the done. 313 00:19:28,420 --> 00:19:29,500 So far, so good. 314 00:19:29,500 --> 00:19:32,710 Let's now move to the last example. 315 00:19:32,710 --> 00:19:37,300 The last example is the array example array. 316 00:19:37,960 --> 00:19:39,790 So the arrays, that is each. 317 00:19:39,940 --> 00:19:42,910 So the array is like a list. 318 00:19:42,910 --> 00:19:45,040 You have a list of items. 319 00:19:45,280 --> 00:19:52,180 And as we can see over here, here is the name of the array list equal. 320 00:19:52,450 --> 00:19:54,610 Then we have the parenthesis. 321 00:19:54,610 --> 00:20:01,510 We open parentheses, just we have single parenthesis beginning and at the end then here is the items 322 00:20:01,510 --> 00:20:03,340 inside this array. 323 00:20:03,340 --> 00:20:11,140 So and we need to type the items or the value of each. 324 00:20:12,560 --> 00:20:14,570 Uh, index. 325 00:20:14,600 --> 00:20:16,700 I will explain what I mean by the index. 326 00:20:17,360 --> 00:20:25,250 The index is like, uh, you can compare them like a storage. 327 00:20:25,790 --> 00:20:31,400 So the first, uh, storage is zero. 328 00:20:31,850 --> 00:20:35,390 This is the index or the number of that. 329 00:20:35,390 --> 00:20:37,130 The first storage is zero. 330 00:20:37,160 --> 00:20:38,960 This is the index zero. 331 00:20:38,990 --> 00:20:44,630 This is index one and this is index two and this is index three. 332 00:20:44,810 --> 00:20:48,110 So for the array we start. 333 00:20:50,040 --> 00:20:55,530 The numbers when we start the index from zero. 334 00:20:56,010 --> 00:20:57,360 Then we go to one. 335 00:20:57,390 --> 00:20:59,580 Then we go to two, then three. 336 00:20:59,610 --> 00:21:01,620 So this is the index value. 337 00:21:01,800 --> 00:21:08,790 So if I will say what is the index value of the index value on list array? 338 00:21:09,360 --> 00:21:15,660 The index zero, let's say the index zero of the list array is sent to us. 339 00:21:16,050 --> 00:21:19,170 What the index value. 340 00:21:19,830 --> 00:21:23,400 What is the value of index two? 341 00:21:23,430 --> 00:21:26,610 So here is 012. 342 00:21:26,640 --> 00:21:27,480 It's fedora. 343 00:21:28,500 --> 00:21:31,410 And what is the index value of? 344 00:21:31,410 --> 00:21:33,570 What is the value of index three? 345 00:21:33,600 --> 00:21:34,470 It's upon two. 346 00:21:35,310 --> 00:21:37,020 And so this is the array. 347 00:21:37,380 --> 00:21:38,760 And we have the for loop. 348 00:21:38,760 --> 00:21:42,750 I already explained the for loop, but there is something interesting over here. 349 00:21:42,750 --> 00:21:48,030 We have the echo message and here the the dollar. 350 00:21:48,750 --> 00:21:51,310 Then the value, the variable x. 351 00:21:51,310 --> 00:21:57,310 It means that we would like to print the value of the variable x is. 352 00:21:58,090 --> 00:22:02,380 And here is the the interesting part. 353 00:22:02,650 --> 00:22:04,040 So here, why? 354 00:22:04,040 --> 00:22:12,610 Why I wrote it like that way because I would like to print the items inside the array. 355 00:22:12,640 --> 00:22:13,750 The list array. 356 00:22:14,080 --> 00:22:16,320 So as we can see, here is the dollar sign. 357 00:22:16,330 --> 00:22:20,530 So we use the dollar sign, then the braces. 358 00:22:20,530 --> 00:22:28,180 So we open one press here at the beginning and then as last press at at the end, then the name of the 359 00:22:28,180 --> 00:22:29,500 array, which is list. 360 00:22:29,530 --> 00:22:31,240 Then between. 361 00:22:33,420 --> 00:22:43,320 The sea here between the brackets, we put the value of the X. 362 00:22:43,320 --> 00:22:46,680 So all of these, because we are using the dollar sign at the beginning. 363 00:22:46,680 --> 00:22:48,390 We don't have to put the dollar sign here. 364 00:22:48,390 --> 00:22:58,740 So the dollar sign that's outside the the, the, the braces, then the name of the array, then brackets, 365 00:22:58,740 --> 00:23:03,060 then we're going to print the value of X. 366 00:23:03,360 --> 00:23:06,990 Let's run this script. 367 00:23:08,250 --> 00:23:13,800 So arrays enter, as we can see over here, let's say cat arrays. 368 00:23:14,490 --> 00:23:17,670 So here is the value of index zero. 369 00:23:18,210 --> 00:23:26,310 So this is index zero is sent to us and the value of index one is read had the value of index two is 370 00:23:26,310 --> 00:23:31,980 fedora and the value of X of index three, it's up one, two. 371 00:23:32,190 --> 00:23:33,880 And how did we bring that? 372 00:23:33,910 --> 00:23:35,620 We use the for loop. 373 00:23:36,220 --> 00:23:37,900 So this is the condition here. 374 00:23:38,290 --> 00:23:39,640 Zero is zero. 375 00:23:39,640 --> 00:23:40,900 Less than three. 376 00:23:41,500 --> 00:23:42,070 Yes. 377 00:23:42,070 --> 00:23:42,730 True. 378 00:23:43,000 --> 00:23:46,360 Then we're going to print this line and increase. 379 00:23:46,360 --> 00:23:48,430 Also increase the value. 380 00:23:48,580 --> 00:23:53,560 So we're going to print zero here as the first value. 381 00:23:53,560 --> 00:24:01,120 Then we're going to print the value of index zero and we're going to do that till we're going to reach 382 00:24:01,120 --> 00:24:04,930 two for four. 383 00:24:04,960 --> 00:24:07,120 Is it for less than or equal three? 384 00:24:07,120 --> 00:24:08,350 No, that's false. 385 00:24:09,130 --> 00:24:10,240 This line is false. 386 00:24:10,240 --> 00:24:13,390 Then we're going to jump to the end. 387 00:24:15,100 --> 00:24:17,680 So that's conclude our session. 388 00:24:17,680 --> 00:24:19,420 Thank you very much.