Now, the essence of this script is to rewrite to uppercase, so I am going to use echo hello
pipe tr lower between square brackets, that's a typo, to upper between square brackets.
And there you can see that it has hello in uppercase.
Now this time we don't need echo on a fixed value, but we need echo on a variable.
So let's write a script, lab18, and in the script we start with binbash, and then if
no argument was provided, script to print an error message.
So I should say if minus z dollar one, then echo you have to provide at least one filename
as argument.
Echo exiting now, exit three.
The number behind the exit really doesn't matter, it has an internal meaning only, and
I'm using fi to close it.
Then I'm using for i in dollar at, I like dollar at because it refers to all of the
arguments.
Do, and what are we going to do?
Well, we are going to do env dollar i to, yeah, to what?
Well, to dollar parenthesis, echo dollar i, pipe, tr, lower, upper.
Now what is going on here?
Well, what is going on is that we are moving the current element in dollar at.
Let's say that dollar at currently has the value of file one.
Then env is going to move the current element, so the first part is easy.
Dollar i is just a current value, file one.
Then the construction with the echo and the parenthesis is what you call command substitution.
So the second argument to env is the result of the command substitution.
And what is the command substitution doing?
Well, it's taking the current value of dollar i, and it's rewriting that from lowercase
to uppercase, and that should be doing it.
So I'm using touch file file one dot dot nine to create a range of files, chmod plus x lab
18, and let's run lab 18 on file one, two, nine.
That should be doing all right.
And now what is the result?
Well, as you can see, the result is that it has written all these files to uppercase.
So something like this is what I had in mind for the solution for this lab.