 Hello everyone. In this video, we'll be discussing about shell scripting variables and how file sourcing is done. So by the end of this video, students will be able to demonstrate the use of variables and file sourcing in shell scripting. So this would be a very good moment to understand the basic block diagram of Unix system, which is going to simplify the use of variables and file sourcing in shell scripting. So this is the diagram where we have seen that there is a shell in between the kernel and the application layer. So if you have this knowledge of how to access the hardware, maybe you are connecting some sort of USB drives to your USB port on a computer, and then you want to access it. You need to access it through an application, then probably you should be capable enough to write a shell program to write a command which would access the definite hardware which you are interested in. So this is quite possible if you are known to this basic block diagram of Unix system. So let's get into the demonstration now. So we have logged in into the Ubuntu operating system. Now the first task is to open the terminal. We are logged in with the guest access having a name called root 1. I'll first of all make sure that I'm logging in with admin privilege. So I'm going to make sure that I'm logging in with admin privilege. Now on the screen what I have is I have logged in with root access into this one. Now before doing anything, let us first of all create a small folder within which we are going to have created a folder called example. I'll enter into the folder called example so that whenever I type, we'll be able to list down only the files that we have created for this particular respect to session. Now I'll first of all try to access where I'm currently logged in. I'm logged in into home root 1 example folder here. Let us first of all write a small shell script. So for that I'll be using the usual nano editor. Nano I'll call it file.sh. So the name of the file that I've created is file and I'm trying to use nano editor for editing it. So remember that the first line of any shell script is referred as shebang. So which stands for an indication so which actually indicates what shell is actually native for your operating system. So the best way of what must be the shebang or the first liner of your shell code can be identified by typing a command called so as we are already aware that echo is nothing but it's similar to something like print up statement in your C language or a statement which is responsible for displaying some content to the STD OUT. So I'll try to print echo shell. So this is a system wide variable which is by default generated by the operating system. It's all by the operating system itself at the time of installation. So when I hit enter you will be able to see that we currently have support of this bin slash bash. So I will type the same thing in our program. So this is the first line which is referred as shebang which gives the user for example if I'm writing this shell script code and a second user is trying to read my code and he'll be able to understand that yes the whatever code that this particular file is being written in is based on the bash scripting language. So those shell scripting has very few types of varieties like the con shell or the C shell or the bash shell which is nothing but an improved version of our shell. So whenever you have the support for bash or whenever you are able to see the written type of echo dollar shell as slash bin slash bash it's a meaning that your operating system is a born again shell. So that's the type of the shell which is being supported by your operating system. So once you are ready with the shebang this has to be written in every shell program that you will be writing henceforth. The next part of the shell is comment. So whatever comment you want to write that can be prefixed with a hash sign. So whenever you write something with the help of a hash sign prefixed with that one that is by default not considered by your file as a command. So it can definitely improve the readability of your code and it's always a good practice in programming languages to write your code or equip your code with lots of comments so that whenever a third person is trying to read your code it becomes more readable. Now apart from this here we are going to write commands. Now let us say I want to list it down or I want to simply print a name called waltz. So that whenever I am saving this file by pressing control X and then enter and then sorry after control X you need to press Y and then enter. So this has saved my file now if I simply try to hit LS it will show me the list of files and folders which are available under this current folder. Now under this directory you already have a single file called file.sh which has only read access. So I want to first of all make it executable. So the command for that is going to be chmod plus x so as we have already seen this command in the previous video I'll show you another method of making a particular file executable. So for that you can simply go for chmod then minus r stands for recursive and then simply put a triple seven and then write the name of the file. So now if you try to check you will be able to identify that file.sh is now displayed in green color it's a meaning that it is by default now an executable file. The first part is once you are aware of executing a file you need to understand something about sourcing to the shell window. Now when you try to edit the same file again let me introduce you few things like I want to define a variable. So similar to any programming language here also you have access for a variety of variables but the good part about shell scripting is that you need to simply write things like this. So I'm simply writing name is equal to waltz and then I want to print the same variable. So for that as you can see similar to any programming language name is the variable here waltz is the actual content that I'm trying to store inside this name variable then I want to display the content inside this name variable. So for this what I need to do is use a dollar sign followed by name of the variable and then simply save it. Now if you try to execute this so the part of execution is referred as file sourcing to the shell. So there is a basic difference between the methods which can be followed. So if I simply put .slash file .sh it is executing inside I mean executing inside the same shell so that the output is visible here itself whereas if I try to source the file to the bash by using a second method where you are supposed to write source and then the name of the file .sh then you can see that it is displaying the content of the file also. So there is a difference. So currently as of now you are not aware I mean you are not able to see the difference here but in the back end the basic difference is that whenever you try to execute a file it is executed within the same instance for example if I'm trying to source a file it's a meaning that I'm trying to source the bash available in my operating system with a shell file called file.sh so in the back end it is going to open up another instance and then it executes everything there and then whatever output you are getting there that is actually printed on to the screen here. So there is a very tiny difference between executing a file and sourcing a file so it needs to be taken care of whenever you are about to handle these kind of activities. So that's all for this video here are the references used for this video thank you.