 OK, this video is obviously part of a series. Be sure to check out the description of this video for a link to the full playlist. Today we're going to be creating a shell script, in particular a bash shell script, and we're going to pass it some arguments. So in previous videos, we used the read command so the user could type stuff in on the keyboard after being prompted. But let's say we just want the user wants to be able to run the script and already give it its arguments, its parameters. We can do that. So let's go ahead. I'm going to use Vim as my text editor, whatever text editor that you feel comfortable using. I'm going to type, just call my script arg.sh. And now this is a bash shell. So I'm going to start off with my shebang line, which is pound, exclamation mark, forward slash bin, forward slash bash, telling it what interpreter to use. Now let's just say I want to have the program say hello to the user. I can say echo hello. And then how do I get the username? Now we could use the read command, or we could also use a combination where we can check the value if one is given at the argument on the command line to use that. And if not, then to ask the user. But we're going to skip over that part. We're just going to go straight to assuming that the user has entered in a name. So at this point, I'm going to say hello, dollar sign. And I'm going to say one. And I'll explain that more in a moment. So now I can save that. I can make it executable using change mod and then giving the name of the script. So now that script is executable, it can be run. If I just run it like so dot slash, again, the dot slash means current directory saying we're writing a script that is in the current directory. It's not in a system path somewhere or anywhere else. And if I enter, all we get is hello because we didn't give it a name. So let's say I say hello, Chris. It will say hello, Chris. What if I say hello, Chris Smith? It still only says hello, Chris, because each space is considered a new argument. And what we have here, we actually have three arguments, if you will. And they're all numbered in the order that they come. So 0 is actually what you've typed here, the name of your script. So if at any point you want to let the user know what script you're running, you can utilize that, which comes in handy in some scripts. This would be 1, and this would be 2. So we have some options here. I can go back into my text editor. And I can add an line here. I can say, echo, you are running. I'm going to put this inside quotations. The script $0. Go back out after saving that. Run the script again, hang up our a few times to go through my history here. And you can see here, it says, you are running the script, and it gives the name of the first argument, which is whatever program you're running. And then we said hello, Chris. So we still have this hello, Chris. Let's say we want to say Chris Smith. There are two options I can do here. I can go here, and I can put in quotations this. So now it's ignoring that space. It's seeing that the quotations are here, and seeing this all as one argument. Boom. So now it's saying, this is the script you are running. And then it's also saying hello, Chris Smith. If I go back into my text editor, another option would be if I wanted to separate the first and last name or the first and second argument. I can also say $2. And now if I run this without the quotations, it says Chris Smith because it's echoing hello, argument one, and argument two. And you can sort of forth and so on as many arguments as you want. And in this particular way, you're looking at the arguments have to be put in a certain order to do it this way. So obviously, if you want the user input a first name and the last name, they have to put them in the proper order for this particular way of doing things works. Two other things you can do. I'm going to go here and say, oops. Echo dollar sign. Remember dollar sign means a variable. And these are just special variables. I can say dollar sign and the at symbol. And I can say dollar sign and asterisk mark, the little star mark there. Now if I run my script, you'll see that we have a few different things here. We have hello, Chris Smith, and hello, and then Chris Smith and Chris Smith. Both of these denote to use all parameters excluding the first. So one on. So I can have as many arguments as I want here. And you can see that they output, both of those will output the same thing, all arguments after zero. If I go back into my editor here, let me change the second one to dollar sign pound, or number symbol, or whatever you call it in your country. In the US, we call it pound. I know other countries call it other things. And now I can hit Enter here. And it tells me how many arguments I have. It says eight. We have one, two, three, four, five, six, seven, eight. Excluding the first, which is zero, which is the name of your script. And again, quotations around stuff will change things. This is now all three. These are considered one argument. So now if I hit Enter, you can see that it says six, because two of those have been put in with another one. So we've removed two arguments. So let's a quick look at giving parameters or arguments at the command line for your shell. Again, you can use the if then statements to check to make sure arguments have been entered. And if not, you can then use the read command to request them from a user or output a message telling the user how to properly input them. I thank you for watching. As always, I hope that you have a great day.