1 00:00:00,000 --> 00:00:13,920 Now, the essence of this script is to rewrite to uppercase, so I am going to use echo hello 2 00:00:13,920 --> 00:00:25,840 pipe tr lower between square brackets, that's a typo, to upper between square brackets. 3 00:00:25,840 --> 00:00:29,680 And there you can see that it has hello in uppercase. 4 00:00:29,680 --> 00:00:35,680 But this time we don't need echo on a fixed value, but we need echo on a variable. 5 00:00:35,680 --> 00:00:45,799 So let's write a script, lab18, and in the script we start with binbash, and then if 6 00:00:45,799 --> 00:00:50,200 no argument was provided, script should print an error message. 7 00:00:50,200 --> 00:01:04,320 So I should say if minus z dollar one, then echo you have to provide at least one filename 8 00:01:04,320 --> 00:01:07,440 as argument. 9 00:01:07,440 --> 00:01:13,160 Echo exiting now, exit three. 10 00:01:13,160 --> 00:01:17,879 The number behind the exit really doesn't matter, it has an internal meaning only, and 11 00:01:17,879 --> 00:01:20,440 I'm using fi to close it. 12 00:01:20,440 --> 00:01:27,160 Then I'm using for i in dollar at, I like dollar at because it refers to all of the 13 00:01:27,160 --> 00:01:28,160 arguments. 14 00:01:28,160 --> 00:01:30,040 Do, and what are we going to do? 15 00:01:30,040 --> 00:01:37,559 Well, we are going to do env, dollar i, to, yeah, to what? 16 00:01:37,559 --> 00:01:51,480 Well, to dollar parentheses, echo, dollar i, pipe, tr, lower, upper. 17 00:01:51,480 --> 00:01:53,559 Now what is going on here? 18 00:01:53,559 --> 00:02:00,279 Well, what is going on is that we are moving the current element in dollar at. 19 00:02:00,279 --> 00:02:04,839 Let's say that dollar at currently has the value of file one. 20 00:02:04,839 --> 00:02:09,440 Then env is going to move the current element, so the first part is easy. 21 00:02:09,440 --> 00:02:12,720 Dollar i is just a current value, file one. 22 00:02:12,720 --> 00:02:19,240 Then the construction with the echo and the parentheses is what we call command substitution. 23 00:02:19,240 --> 00:02:24,880 So the second argument to env is the result of the command substitution. 24 00:02:24,880 --> 00:02:26,880 And what is the command substitution doing? 25 00:02:26,880 --> 00:02:32,440 Well, it's taking the current value of dollar i, and it's rewriting that from lowercase 26 00:02:32,440 --> 00:02:35,639 to uppercase, and that should be doing it. 27 00:02:35,639 --> 00:02:43,520 So I'm using touch file, file one dot dot nine to create a range of files, chmod plus 28 00:02:43,520 --> 00:02:53,199 x on lab 18, and let's run lab 18 on file one, two, nine. 29 00:02:53,199 --> 00:02:55,039 That should be doing all right. 30 00:02:55,039 --> 00:02:56,039 And now what is the result? 31 00:02:56,039 --> 00:03:01,520 Well, as you can see, the result is that it has written all these files to uppercase. 32 00:03:01,520 --> 00:03:05,639 So something like this is what I had in mind for the solution for this lab.