 Hello, everyone. In this video, we'll be discussing about shell scripting parameters. So here are the learning outcomes. By the end of this session, students will be able to demonstrate the use of shell script parameters. So this is the basic outline of this video. First, we'll be discussing about what are variables, what we have seen in the previous video. And then we'll be using the same variables in the form of parameters or so-called arguments in a shell scripting. So here it's a good point to recall what do we actually mean by an argument in a C programming language or in general any programming language. So you can pause the video for a while and think on what an argument is in a general programming perspective. So basically, as per the definition, an argument in a programming language is nothing but a value that is passed between functions or maybe subroutines. So as to enable your program to accept some sort of data in the new process of execution. And generally, if you observe these parameters are independent variables and it may contain some sort of data codes or maybe some sort of information, which is going to be beneficial for the upcoming program sequence to properly execute it as per the desired process. And generally, a customized name which is given to this particular process of passing some data or code in between subroutines or functions is basically known as a parameter. So let's now go through some of the aspects which are available in shell scripting. So if you look properly, we have a small table available on the screen here that is parameter versus its corresponding function. So the first parameter that is we have $1 to $9. So this $ by default indicates a variable in shell scripting like what we have seen in the previous video. So basically, we are capable to provide totally nine arguments starting from one through nine. So these $1 to $9, if you mention in your shell scripting execution command, then they actually mean or they actually represent the position of the parameter. For instance, let us say you are executing a simple C program like say addition.c in our terminal and you want to pass two variables in the form of an argument which are supposed to be added in your program. So what I'll do, I'll simply take a terminal and I will issue a command called addition.c probably with the help of some compiler being prefixed to like GCC or some other programming compiler. And then I'll pass two variables like for example, say GCC and then I'll type the file name addition.c and then I'll put a space and then I'll be passing two more parameters that is 10 and 20. So what I'm expecting, expecting the end of the execution of this particular program by hitting this particular command in the terminal, it will be giving me the addition of 10 and 20 which I have passed in the form of an argument. So 10 plus 20 is going to be 30 is what I'm expecting which is to be displayed on the terminal. So similarly, I can pass multiple parameters like for instance, I'm typing the same command again like GCC, some file name.c and then I'm passing integers from 1 to 9 like 1 space, 2 space and so on till 9. Then I'm expecting the addition of or the sum of overall integers 1 to 9 and I'm expecting the sum of 1 through 9 to be displayed on my screen. So the things will be more clear when we get into the demonstration. In the meanwhile, just remember that if you put some braces and if the number of the parameter exceeds above 9, then whatever variables that you pass while executing or issuing the shell command, they are actually considered as positional parameters for arguments after 9. So what is the basic difference between the arguments being passed from position 1 to 9 and 10 to n. So whenever you write an argument whose count is less than 9 or equal to 9, then that actually represent positional parameter for argument 1 to 9 and represent positional parameter for arguments after 9. So whenever you discuss about the parameters and if you are specifically mentioning it from 1 to 9, then it actually represents the positional parameter for the argument in the given command. Similarly, the only difference between these two is that here you need to mention the bracket. That is whenever you have any command and if you are trying to pass some sort of parameters which are less than or equal to 9, then in those conditions you may say that you need not to put any braces here as we need to put a brace for all those numbers which are double digit. So it is a simple method of remembering these things. So whenever you have more than 9 number of parameters in a given shell command, then you need to specifically put these curly braces along with the dollar symbol. Similarly, dollar 0 is a kind of a mechanism which actually displays the file name itself. So as we were discussing about an example of executing a C program through terminal, I said GCC filename.c. So to this compiler command called GCC, the first filename itself is going to be the 0th command. So this is how the things actually work in the back end. That is when we have a parameter mentioned like dollar 0, it holds nothing but this argument is nothing but the filename itself. Similarly, we have upcoming commands. So we will be first of all going through the demonstration of all these parameters or a few of these parameters. So let us get into the demonstration. So I have already opened a terminal and as you can see I have logged in with a user called root 1 and I am not an admin. So it is always a good what we call a method. It's always a good mechanism to do the things being an admin or having root privilege. So as usual, we are going to first of all log in as an admin and for doing this, I have simply typed the command called su and then I have hit the root or the admin password. Now as you can see, I am root here. Now we'll write a couple of things. I would like to use a compiler or an editor for editing the shell script called this. And let us call it parameter.sh. So this is a simple editor called nano where we can type the shell commands directly. And don't forget to put the shebang in this. That is, we are going to use this one. This is by default the basic first line. Now what I want to do here is I just want to, so as you can see, I am simply trying to print a statement called the name of the script is, so I am going to simply type $0. So $0 is nothing but the name of the file itself. So what I'm expecting whenever I execute this particular command, I should be able to see this para.sh as an output. So let us quickly save it run. So we need not to forget this general thing where we can check. Okay, so we have this para.sh as an executable now. Now I'll simply execute this. Okay, as you're able to see the name of the script is para.sh. So why am I getting this as an output? I'm getting this as an output because we have mentioned $0 as an argument which I'm passing to this command called echo. Similarly, we can add one more statement. I would like to add a line gap in between both the statements for better readability of the code always and it's a good practice and a convention whenever you program. Okay, next what we have is I'm going to echo. So the first argument is $1. So we'll go for three commands. Now let us save this and check what it prints. We need not to again convert the mode and all. I'm going to just run it. Okay, so as you are able to see, I have executed this para.sh and as an output what I'm getting, I'm getting the name of the script is dot slash para.sh. Okay, that's fine. The first argument is nothing. Second is nothing. Third is nothing. Okay, so I'll quickly execute this again, but this time I'm going to execute with some sort of parameters. That is the first number is going to be the first argument is 10. Second argument is 20 and the third argument is 30. And let me pass the fourth argument as well, which we haven't taken care of in the program. Okay, so as you're able to see, it is displaying the name of the program very much correctly. The first argument, second argument, third arguments are printed correctly. But the fourth argument which we have used in our command of execution of the parameter is not considered. It's a reason because we haven't mentioned anything about what is to be done with the fourth parameter in our program. Here are the references used.