 command line arguments. As I said that the required information for our simple shell script had to be in students.txt and you might want that different file names are specified. You do not want to each time copy that into students.txt. You want to keep different different files. How do we do that? So, for example, look at this. After doing all this, the redirect is from here. The redirection is taking place to a particular file and inside the marks directory, inside the marks directory $1. Let us go to the previous slide just for a minute. Here it is results.txt. Each time this marks one whatever is there in marks one, some cutting, pasting and all is going on. Students names are coming from here. But finally the output is going to students.txt. Tomorrow you run it, again the old results.txt will get overwritten. I already told that this is greater than sign. There is no interactive mode. It will certainly override. Each time are we going to open nano editor and modify this from results.txt to results1.txt? No, there is a simpler way. We will say that that $1, that particular information will be provided from the command line. We will say when we execute this particular file, then we will give an argument to this particular command. We have created this new command. Only when we are running it in command mode, when we have given execute permission to it and we are giving running it in command mode, that time we will give another argument. What is that argument going to? Where will it go and play a role? It will become, it will take $1. Wherever $1 you have written, it will go and sit there. So, the way it is written here, it will expect you to specify the file name results.txt. Then next time you can say results1.txt. You can say result based on a date. Results6thNumber.txt. Results7thNumber.txt. Each time the file name can be specified from the prompt now. We can see a simple example. For example, let us open nano and catting. We had redirected this to file1.txt. If we do this, when this particular script is executed, that time the output will get return on to file1.txt. If you execute it again, it will overwrite. In the second time, you might have different information. How to change this? That also we will see. Each time it will overwrite to the same file. That is what we are not happy about. Why do not we say, we will provide that information from the prompt when we are executing it. So, we will just write $1 here and we will, now when we execute, now we will say $1, $1, $1, $1, $1, $1, file1.txt. Previously, when we executed, we did not give any argument. There was no requirement to give any argument because there was no $1, $2, anything inside. So, now file1.txt has got created. If you say, no, not file, another, another one, we will give different file name as an argument. Cat, file another. It has written output on to this file. So, now we are able to specify from the command line. You do not have to go and make the changes by opening nano editor and making this change. All that is not required. We can directly give that from the command line. What about more? Can we give more? If you give something more, sorry, to this command, if you give more, so our convention is, whenever you have this command prompt, this is called $0. This is called $1. The first argument, the command name itself is called $0. First argument is called $1. What is this? This is actually $2. Second argument to the command catting.sh. This is third argument. If you give unnecessarily many arguments, there will be no error. Why? Because $2, $3, $4 are anyway not being asked inside catting.sh. It will not give any error. It will just do whatever is supposed to be done to $1. Only $1 has been called. It will do that. How will these play a role? Maybe you want students.txt, not student.txt. You want the input to also come from somewhere else. So, that can be different arguments. This is how you can make new commands with different, different number of arguments. Different number of arguments. Always note, first one that comes after the command is $1. Command itself is called $0. In some really advanced usages, you need $0. Not in general. This is $2. This is $3. $1, $2, $3, all of these you can utilize. For example, nano. This can be executed then echo $2 was not required. Another, let us see file, $3. This can be different, different commands inside the same script. What does it do now? If $3 is already been called $2 then it is not required. So, anyway, whether it is really required or not is debatable. But we have made all this. Why do not we execute this? So, first thing it has done something. Then it has taken $2 and said, and it has put the $2 precisely here. Echo $2. It has done $2, echoed it. Was not required it said. What about this $3 has come here? What is $3? $3 was precisely here. What happened to $3? It said file $3 we wrote. It is trying to open this file. This file is not there. So, $3 file is not there. Can not open it. If you give a reasonable $3 then that will execute properly. $4 did not even play any role. Why do not we say students.txt? So, this is the execution of the second line. That is not a comment. This is the execution of third line. It has said students.txt is a ASCII text file. This is what would come with file. This is that particular execution. One can use multiple input arguments. $n, let us go back to the slides. $n corresponds to the nth command line argument. Nth command line argument excluding the command itself. It can be run as shown below. Let us see what is there. Path. So, we said that this results.sh, results.sh first of all was not found. Catting.catting.sh was not found. Even though you gave execute permission to it, it could not find it. Let us try to do like this. Then it at least found it. We know. Of course, if we execute it like this then it will ask where are those $1, $2 you promised already inside that shell script. You are calling $1, $2. You have not even given it. It will say look all these errors. Do not worry about the errors. Errors have come because $1, $2 have not been provided. But importantly you have specified saying where is this catting.sh file you are trying to execute? It is in the current directory. Why did you have to specify it? Because why do not you see where is the path? All this command rm, unique, where are these files? If Linux says that it is open source, you are able to see the files. You are able to see the source code for each file. Where are they now? Are they hidden somewhere? Why do not we see path? This path will tell where all each one of you try path on your own computer. It will be different. In mine, I have many of my own special, not many, three or four, my own commands which are kept in my home directory in one dot bin directory. But any other, any command we type, it will look for that file. First it will look here. Then this is column which is separating. Then it will look here. This is all plenty of absolute paths. Then it will look here. These are all different, different directories where various commands have been kept. So for good reason it will look in games also. But it will look in games only if it is not found here nor has it found here, etcetera. So this path, the sequence in which you give all this is also important. If the same command name was there in multiple, multiple directories, it will locate, as soon as it locates it in this, that same might have been here, but it will not even try to search it. It will try to execute from the first, first directory available in this path. So if you put the scatting node SH in one of these places, then it will not ask you to put dot slash catting dot SH. So my own commands are put in dot bin directory. So let us see the next slide. Control structures and operators. This is an important thing. In bash we can write a plenty of, plenty of if, else statements, for loops, while loops. You can also see whether this is greater than that, whether this is true, whether a file exists. We do not want all these errors like file, file dollar four. As soon as there is an error, it will stop executing. And we do not want some big script, many things to be executed, one error somewhere and it stops executing further. Because of that we always want to test whether some file exists. If the file exists only then you will do certain operations. So test is very useful for these purposes. So a whole lot of tests also can be done, whether if this is equal to that then you do this. If this is less than, greater than, so man test will test in detail. So we will see some if, else examples. What does this say? You can write a small shell script. If test minus d, dollar one. What is this d now? How are we supposed to know? Man test. This is always tell us all these various options. Incidentally it says print the directory if it exists. If the directory dollar one, what is dollar one? Whatever will be provided as the argument to this, first argument to this command, which command? Whatever file name you save this, you save this into a file name then you have to give it execute permission and run it as a command now. Only then this dollar one, dollar two all those will work properly. Now you can check if you run this in dot space, cat, dot, s, h then this dollar one, dollar two all those counts will go wrong. This is if, if the directory exists then yes the directory is present. Which directory? This dollar one will come here. If it is not there then this test will not execute and whatever is written inside the then and the fi will not, will not be shown on the screen, will not execute. How do you, if you start with the i f you will end with f i. If you start with f, if f i the reverse that is how you will end this. We can see some more examples on the prom. What is this? We are giving a number now. If that number is less than this, so why do not we, this one we will do this. So, for all for typing all this right now we recommend you to use a nano editor because it opens from within the terminal. Later on today we will spend some time on some other editors also. Why other editors? You might be used for example, nano, new file. Convention is give s h extension because it is a bash script. In all this typing the mouse is not helping, the mouse is not playing a role. You have to do copy, paste of various lines. You cannot use a mouse. If you want to use a mouse you want a simple plain text editor in which the mouse is also useful then please use g edit. G edit is another editor. It opens a graphical user. It has better graphical user interface for those who are used to using the mouse for copying, pasting then you can use that. Here also copy paste is possible. Simplest way copy paste is possible is by marking using a mouse. So, let us start with this and we will see as we go on. So, if test minus d, this is the first thing we were seeing, directory name. Better to indent. The slides do not say it should be indented, directory exists, echo. We can have multiple, checked for directory name. Some commands can be put. So, what is that cat, new file, make directory. That directory was not there. That is why nothing came on the screen. Now we will execute this. The directory exists, checked for directory underscore name. Because the directory exists we just now created it. Can we do it like this? Again some permission problem. Like before please change permission each time. Now, of course, we want to check for different, different directories. There are so many directories. Test underscore directory. Test underscore directory now if you want to check for that, we will have to again open, go to nano and open it. Why do not we once and for all go and change it to dollar one. And whatever directory it is checking, why do not we put only that here? I can understand all these colors and all are not visible. I can change that here. So, cat, new file. Now whatever it is required to check existence of which directory that will be provided from the command line. Now, why do not we see dot, yeah, that directory exists. Which directory? Now you gave nothing. Test. Even if you give nothing, it turns out that existence of directory will tell yes. It has checked for nothing and still said yes. Test passed. Important for you to note this. Check for so and so directory. Yeah. The directory exists. What about this? Now also, yeah, it has not taken anything. So, please note that when you are using dollar one, do not execute it in such a mode. Even SH, new file for directory is luckily things are working. It might give an error in general. Yeah. We might also want to say else. If this is true, then do this. Else do something else. That construct is also very much possible. But then the purpose of this is to check whether some number is greater than 0, less than 0. Why do not we check that? Num check. If dollar one. Less than. Less than is by definition strictly less than. L e q I think is for less than or equal to less than 0. Then given number is negative. Else, how do you cut a line? There are all this stuff. Cut. You can cut a line. You can uncut it. Control K. Else echo number is 0 or positive. Yeah. F i will end it. Num check has not been given. That is why, that is why tab will not work. Because it does not have execute permission. Even if you tell this, it will not work. Change the permission, then the tab key will work. Number is 0 or positive. 9 3. So, I made a mistake. I forgot to write test. So, I forgot to write test here. It has executed. It was trying to execute 56 itself. Number is 0 or positive. Yeah. So, for some simple things, for some simple checks, test word is not required. It appears. What about minus 56? Given number is negative. So, that is how one will execute our shell scripts with dollars, with if, then. So, now next thing we can see is. Any doubts about this? It is a good time to ask for questions. Please. So, we want a question from Jaipur college. So, please ask a question from Jaipur. Hello, sir. Sir, how many arguments we have passed through the command? Any number. Have you ever having any maximum limit? There is no upper limit. Any number? Yeah, any number. For all practical purposes. Okay. His question is, we have dollar 1, dollar 2, dollar 3. How many arguments can be given? Many. Yeah. There is no, there is no upper limit. Maybe there is some upper limit, which is really large and we do not have to be concerned about that. Okay, thank you. So, thanks for the question from Jaipur. Now, we will connect to Donbos to Guati. Hello. Sir, in such case, you have shown us to pass numeric arguments from the command line. So, if I pass R 2 5 from the command line, how do I know which sign is better or which sign is smaller? In such case, in such case, how much they can. So, if I understand your question is, for the test, test is itself like a command. Yeah. For the test command, if you give minus D option, then it expects a directory name. It expects some, some letters, possibly numbers or possibly alphabets. But if you have minus LT as an option, then you are expected to give a number. If you give some file there or if you give some characters, then what will happen? I understand. That is your question. What will happen? I do not know. It is not a valid way of using test and it will exit, maybe test will give an error and it will exit prematurely, meaning it will not exit the correct way and the problem with that is whatever further commands you have written in that file will not execute anymore. It will just exit suddenly. So, test is required to take a number if you give minus LT after it. Then, dollar one has to be a number in that case. Yeah. We have a question from St. Joseph College, Kerala. How can we get the number of arguments in the command line? So, you, the question he asked is, inside a, inside a script, you would like to know how many arguments were given to this command. Some of them may not be required, some of them are actually required, but they were not given. So, you want to have a check. How many arguments were given? Yeah. So, there is certainly a way to do this. Just that I am not able to remember now. It is possible to have a count of how many arguments were given to the current command. Yeah, that is really important for writing big shell scripts that is required. So, during the T break, if we can find this out, if Shrikant can help about this, we will let you at the end of the T break. That is a really important question of knowing how many command, how many arguments have been given to the current command. From within the command, you want to know this. Yeah. Okay. Any other question? As far as you understand, you are saying how to, if you are given the path, I had added some dot bin in my own path. How do you add something into the path? Yeah, given a path, how to add further? Yeah, this is a very important question. Yeah. So, how to add a path is important. We will have a look soon. Yeah. Any other question from Saint Joseph Kella? Please ask a question. We are connected to Somaya College. Please ask. How to debug the shell script, sir? How to debug the shell script? For many programming languages, there is a so-called debugger mode. Yeah, for big shell scripts, for big long codes, it is recommended to use a debugger mode. At least, personally, I have not done so much programming. I have not done debugging. But Prasanth, sorry, Srikant Patnaik here tells me that bash DB is the debugger mode, which will allow you to stop as soon as there is an error. Yeah. So, for those who are used to using debugging mode can use that. But you can just run the script and the error will come on the screen and only that it will exit wherever there is an error, it will exit there. Yeah. So, debugger mode is encouraged to be used. Bash DB is what the command is. So, it has to be installed. Yeah, it is not in the default Linux installation. It is to be installed using, for example, Synaptic Package Manager. Yeah. So, let us go back to College of Engineering, Baramati for their question. How to have more than one pattern in Grape Command? So, yeah, this is a very important question. How to search for more than one pattern in the Grape Command is what we will see now. Yeah, very good. Any other question from Baramati? Sir, my question from yesterday's session is that. Yeah. How to list only directories using LS command? Yeah, how to list all the contents or only list all the contents, LS minus L. Okay, sure. We will see that. We will see how to list what is the directories. So, the question from Baramati was how to look for multiple patterns inside a file. Yeah, if you have more than one pattern, as soon as you have more than one pattern, one has to specify some more options. That is what we will see now. Another question from Baramati was how do you list only the directories inside a file? Yeah, there might be many files and you are interested only in the directory name. How to list only the directory? So, that is also something we will see right now. Yeah. Okay, let us go back to this prompt. So, grep. Suppose you are doing grep, something grep, pattern, file name. This is how it goes. Yeah. So, which file name? File name is not there. So, why do not we say items? So, pattern incidentally is not there in items. We know programming was there. Yeah. So, now that is only one pattern. Programming. Prog is the only pattern. Now, if there is another pattern you want to search for, now you have to be very clear about whether you want to print out the lines that has any one of these two patterns or it should have both of these two patterns. Yeah, as soon as there are two search patterns, whether these there is you are using AND operation on these or OR operation is of course required to be told. So, if you are interested in printing all those lines, which have at least one of these search patterns, yeah, then it is easier. Grep minus E, pattern 1, minus E, pattern 2, etc., minus E, pattern 3, any number of patterns you can stay with minus E option between them and then finally the file name. Yeah, incidentally pattern 1, pattern 2 were not there. Why do not we put something else? Pearls. Pearl. Then we had also looked for man. Then we had also looked for small man. Yeah, these are the different lines that have any one of these. Incidentally, only one of these patterns is there per line, but sometimes more than one pattern also can be on the same line. But we are using OR operation. Minus E means print out every line that has either this or this or this, because pearl. So, this is how you are going to do OR. Suppose now you are interested not in OR, but AND. Maybe one of the options of grep will allow you to do this. If there is only one option, then you may or may not put minus E. Now, incidentally there is only one. Why do not we look for minus I? So, now we have two. Why? Because I means case insensitive. E option you put or do not put does not matter if you have only one pattern anyway. If you have two patterns, then there is a problem. You have to put minus E for OR. But now suppose you are interested in AND. You are looking for all those lines which both have MAN and which also have software. Then you can just pipe it to another grep. This will first it will print out those lines where this pattern is there. And on that output, we are going to run another command. In other words, output of this is going to be piped to grep command again. It is incidental that it is repeat. It is the same command. And now we are going to look for what pattern? This pattern. This is how we will run the OR AND operation. So, this is how one uses the AND. I mean if you are looking for those lines which have this pattern AND also have this pattern. Then what I do for my own purpose is I pipe it to grep again. Some option in grep might allow you to do this without piping it. It is a good thing to look up oneself. As soon as there is one way to do it, I am satisfied. So, please spend time yourself and look for more things not now later because we are doing other things now. So, there is a question on chat saying how can we know how to get how can we find out how many arguments are to have been passed from the command line. So, this we will find out and put on Moodle. I am very sure it is possible just that I am not able to remember now. Help bash man bash might tell you all this, but we will look this up and tell on Moodle because I am also interested in this answer. We will find this out and tell on Moodle. This was the question I think from Saint Joseph Kerala. We will find this out and tell you back. Another question was how to list only the directories. Another question that we will address now is how to append something to the path. So, I had some other solution in mind. If you want to list the directories, then man LS would have given us various options, but then Sighan has been very quick to find this out. LS minus D star slash. It will list out only LS minus D is a important option. So, if you do minus D only, then it will list only the current directory, but LS minus is star slash due to some reason the star slash is also required. Then, oh really minus D. So, the slash is how it is signifying that it should be a directory. If you remove this, then it is listing everything. So, if the slash all the directories notice that the directories have a slash at the end and that is how this is coming. Another option is LS minus L. You know that all directories begin with D. Let us say, we know that what is the important property when you do LS minus L? Directories, instead of dash, there will be D. There will be D on that line, but not anywhere in that line. See, after all this student D is here also. Just to grab for D is not good. Why do not we grab for the D character? This will also be a wonderland. We want the D character to be the first character on that line. This will list all the directory or when you do LS minus L, the output of that is going into the grep command again. And now we are looking for which pattern? Hat D. Hat means beginning of line character. So, now that I have put beginning of line character two times, the end of line character will be upset. That is why let me tell you that end of the line character is denoted by dollar, TXT. So, this will show all the lines coming out from LS, all the lines coming out from LS minus L in which this pattern is there. What is that pattern? TXT is there in the end of that line. End of that line is being intimated by the dollar symbol. So, this is how one can look for patterns happening at the beginning of the line, end of the line, etcetera. This completes the question about how to list the directories. We have already given you two ways to do this. Then there was a question about how to append something into the path. So, we saw how to see what that path is. For that you will do this. So, these variables can easily be updated. For example, name. Suppose you can have name equal to something else, Fossey project. Now, you can also have the same thing coming on the right hand side, name and you can add something to this. For example, colon. Colon is not really required. Fossey project is conducting this workshop. Whether minus sign is important or not, we will see that it might have some other meaning. It is conducting this workshop. It is not really conducting. Different project is conducting. It is not correct to say Fossey project is conducting is speakers for. Now, we will say echo name. So, what is important to note here is dollar name can occur on name, can occur on both left side and right side of the equal to sign. So, because name already was equal to Fossey project, that one has been substituted up to here and the rest has been appended. This appending is very easy for shell variables. This is what we can do for appending something to the path. If you want to change the path totally, then just define it. Absolute path, whatever you want. But if you want to just append something, path is actually getting defined somewhere that is all default that is really important. Meaning when you load Linux on your laptop, path everything are very important variables best is to never tamper with this. The only tampering we will allow you is to append something to this. That appending can be either to a start or to the end and I said that it is really important where the path is. Whether some directory is in the start of the path or the end of the path, this is important. First of all because it will take more time to find your command if that command is in the last directory inside this path. Secondly, if there are multiple occurrences of that file, then if that the command that occurs first is the one that will get found. So, now incidentally I have, I already have dot bin. But you can also path equal to home dot bin. Dot bin is already there, path. This will append. This is how we can easily append. Dot from here onwards was already there, you had already seen in echo. What is it that we have added? We have added this much. To be precise actually colon also we have added now. Did we really write home belur? No, this particular information was up to here was information already sitting inside this variable. This is how one can easily append various things into the path. Any other questions so far? Any questions that we have not answered yet? There is a question from Mufakham Jha College. Hello sir, this is a question related to previous topic before the break between the statement and the statement. Like we can use the test expression as well as the square brackets. So, is there any specification that when you please add a particular instance like test or like square brackets? This is my first question. The second question means whenever we are going to check a output for the negative and the non-negative number. So, whenever I am going to give a bigger number. So, there I am going to have a error like a test integrate some errors occurring over there. So, will you tell me about that? We understood one question, the other question we did not understand. Both questions were spoken very, very fast. You please repeat the second question little more slowly. Okay sir, this is related to the whenever we are going to check a particular output to find the number is a negative number or a non-negative number. So, for that I am going to give a bigger number. Okay. I am getting an error like a mpg unexpected. So, what is that error? Number. No, whenever I am giving a smaller number I am getting the answer. So, whenever I am going to give a bigger number. So, is there any range for that? Did you put the range? Range is there would be some range for every integer. After all these all are finite bit memory and eventually there will be a range. But the range is really very large. We do not have to be worried about it. Maybe 10 to the power 16 or what some really large number. Maybe you give decimal in batch scripts all this number comparison they all require integers. Decimal points are not allowed. Okay. Yeah. I hope that answers the question. Next question is from Perrier. Yeah, please ask. What is different between nano editor and VIM editor? Is there any other editors available for UNIX or line next? The question from Tanjavur is there is nano editor, VIM editor are there any more editors? So, there are plenty of editors. Plenty. Really plenty. Yeah, we will spend some time on what is a good editor. We will spend some time later today. Okay. So, nano of course we started because that is very easy. So, we encourage you to use nano. If you think that you want to do more then you can use VIM. We recommend only these both. G edit also. G edit also we recommend. Okay. Thank you. Like the apropos command used to find any pattern of commands, whether it is any command to find out the shell variables. So, if you want to find the shell variables or what are the different types of shell variables available. Say home is a shell variable, login name is a shell variable like that. If there are any help to find out what are the shell variables that are available. Yeah. Thank you very much for your question. Yeah, it is a good question to know what are shell variables are currently there. So, we will see that in incidentally the next and the second next slide are about that we will see immediately after we finish the questions. Okay. Thank you. Any other question from Tanjavur please ask now. What is the path command actually show? It is showing some user local has been it is showing a long thing and then telling it is no such directory or file. What does it actually tell path s local been? Is there any other question about is there any question from Tanjavur before we start answering these? Madam, I am asking what is the exact how to determine exact path of the current directory. No more questions. No more questions. Okay. Any other question? We could not hear the questions later but whatever questions we have heard we will answer them one by one. Okay. Before that we will take up any more questions from other places meanwhile. Thank you. The next question is from St. Joseph College Kerala. Hello sir. Sir, how can we use grep command to select each word which is matching the pattern? I think the question is you want that pattern to be a word meaning before that pattern and after that pattern there should be either spaces or end of the line character or semicolon or something else but that pattern that you specify should be a word, should be the beginning and end of a word. If that is the question we will answer that. If the question is not that then you please ask your question again. So the next question is from Nehru University Amarabhad. Okay. Please ask. Okay sir. Can we explain about the set and export command related with path command? Set path. And one more question is there related set and export command. Export. Yeah. Export is also important. And set path. And one more question and one more question and give category of cell, how many types of cells are available? This is one kind of base cell. So different types of cells. Cell, we didn't understand what is the cell. Cell, sorry, sorry. Yeah, I understand. Yeah, that also we will tell. The next question is from Amal Jyoti College Kerala. Please ask now. In the example script, to greet the user. Yeah. Given that if a script, the shell script. Yeah. The now variable is assigned a value. Date plus percentage j, percentage d of percentage v what does that a, b, d and all stand for. As soon as we come to that slide we will certainly answer that question. Yeah. So we are happy that you have gone further to the next slides. We will, as soon as we reach there is a good time to answer that question. Okay. Thank you very much. Any other question from there? No, sir. No, sir. Okay. Thank you very much. Okay. So let us, let us look at the various questions asked so far. So one was, is there a difference between using test and square bracket? Both are exactly the same. Yeah. Whether you use, yeah. So square bracket is only a different, it is alias. Alias means just one different wave specifying test. Here of course square brackets are required. Any one of these are equivalent. Yeah. There is no preference, nothing. Whatever suits you is what you can use. Now somebody said that when you type a command some long list, the entire path comes on the screen and it says command not found in, it is not there in this, this, this, this. So that depends what information, when a particular command is not found. Let us go back to this. Some nonsensical command. Nonsensical command. It says command not found. What is the meaning of this? Yeah. It means these are all different, different directories. Yeah. For example, for example this. Look at this. Whatever is highlighted. This is a particular directory. Why do not we list? These are, you can go to such a directory in your computer. There are all these and most of them are shown in green. Some of them are in blue. Blue ones it appears are directories. I do not know. But green ones are all commands. They all have execute permission. What did we do? We listed all the files and directories inside this directory. So any command you tell, any command you ask, it will try to search in all these directories. For convenience, all the commands that are accessible are kept in various directories. Depending on how they are built, who has contributed from some long history of organizing all these commands, they are all stored in different directories. And when you type a command, either the command is found in one of these directories, then it is executed. If it is not found, some shells will tell, it is not found in this, this, this, this, all these directories. Whenever it is not found, it means it did not find in that path. That is why, so user, USR means user. Some are user specific, some are root specific, some are packages, some are extra packages. Depending on how those commands are organized, these are all different ways of organizing this command. The very frequently used commands are perhaps kept here because they are, the ones that are frequently used had better be found first. That is why they are early in the path. So that is just another way of organizing the different files. They are all going to be in the path. Every directory, everything that is between two columns, everything that is between two columns is a directory inside which there are all these commands. All command, every command is actually a file. It is a file with execute permission. Somebody said then how do you, how do you set the path? So there might, I think there is a set path command, set. Set, it is set path, is it? Like this. Set path equal to something. In brackets. In brackets. So I have not used this set, but what is the name? Mayank. Mayank who is sitting here has helped me with this information that you can set the path equal to something and there is some square bracket also required which I have not typed. But man set, man set, there is no manual entry unfortunately. Why there is no manual entry? Please do not complain. Look, there is no manual entry. Why I do not, why I require that you do not complain? You are potential contributors to the manual entry to begin with. Potential contributors to the Linux movement. You can contribute in different, different ways. This here is an opportunity for you to contribute rather than complain. Rather than, with Microsoft we complain. It is not working the way we want. But in Linux we will not complain. Anything that is not working the way we want, we will go ahead and contribute. That is the philosophy of this GNU thing. So set minus help maybe will have some information. It tells some set usage equal to this. Or also help set typically has some information. Here there is some information, at least instead of man. These are different ways of organizing the help information. Man is manual. For manual there is no set. But for help, help set there is some information. Set minus, minus, minus help. There is no information there but at least this usage has come. And it says some square brackets are required etc. Final argument has to be inside square brackets. That is exactly the way Mayank told. So this is another way of setting the path. The one that I told you was there you can append just for shell variables. Another question was how do we see all the shell variables? That is there, that is going to be covered very soon in the slides. So we will not take up that question now. Another question was how do you see all the shells that are, what all shells are possible? So we are dealing with only bash. We will not spend any time on learning any other shell. But let me just list out the various shells. This is not a command you should execute. I am just typing here for you to, rather than verbally saying it, pcsh, csh, ksh, bash of course. These are the various shells, the ones that I know. I think zsh is also there for some strange reason. But we are not going to ask you this in the exam ever. If you do not able to list out which of shells, it will not inhibit your Linux usability. You can use Linux very effectively using just bash and that is also the most popular. Only some advanced guys use more complicated shells. Next thing is, yesterday somebody had asked on Moodle what is the difference between super user and root and super root. I think super user is same as root. There is no difference. Some operating systems do not use super user. They use root, I think. Maybe Solaris, Sun Solaris, they do not use super user. Different operating systems, different companies, Sun after all is Unix. It is not open source, it is not Linux. Maybe some things are open source but not entirely. In open two, I think SU, super user is the one that is used. But root is also, root can be a login. As far as our level of usage of Linux is concerned, they are the same. Please do not worry about any very subtle differences between super user and root. It will not affect us in any case. They mean the same for our purpose. Now another thing is, how do you grep for a particular word inside a file? So let us see again, this is really important. Grep, prog in items. When you do grep prog, for example, let us grep C in items. It has shown all this. C, we are interested in the word C because C programming language. We want to know only about C programming language. C, the word C. We are not interested in this line. This entire line, we are not interested. Nor are we interested in C for compiler. Nor are we interested in this computer programming, this. Why we are interested only in those patterns C? If that C character occurs somewhere inside some other bigger word, we are not interested. So how do we do that? C, just this, what will this do? It will ensure that the letter capital C occurs at the beginning of a word. To the best of my understanding, no, sorry, we have to use this reverse. Please use this slash with slash to use. Do not have to remember. Just try both. One of them will work. This is called forward slash. Those are here are helping me with this. This is called forward slash. Forward slash, we look at it as slide. You sit on the left side and you slide down. Forward slash is sliding down. Now, if you use forward slash followed by the less than, then it will mean beginning of the word. This is an important character actually. But we already saw that this is almost like redirect. This is when the standard input is supposed to come, not from the keyboard but from a file. Because it has its own significance, we are escaping it using this forward slash. Forward slash is in general used for escaping a character. Somebody else had asked on chat, how do you look for a pattern if dollar literally appears inside the pattern? There also you will escape the character. Whenever these meta characters are going to come inside your search pattern, inside your file names, then you will want to say bash, don't take dollar as end of the line. Don't take less than sign as its meaning. Take it literally. So, you will escape it. You will escape the meaning of that particular term. So, now what we have done is we are looking for all patterns that in which C occurs in the beginning. The beginning means what? Not necessarily space before C, like here. It could also mean beginning of the line. Both are allowed. Beginning of word means what? Just before that character, either space or some other, not a number, not alphabet, that's all. But we are interested in C also being the end of the word. End of the word is going to be replaced with greater than sign. But greater than sign itself means redirect to a file. So, we have escaped it with again a forward slash. So, now when you do this, when you do this, it will show you precisely those patterns which end with, start with C, end with C. Of course, this can be PROG. Just prog is not there. Star ending with G. Star here means you can put any a dash z. Any number of letters, maybe this should not be there. So, I am not able to find out. I think it is a graph. It does not work. Dot has a significance, but a dash z. Maybe we need colon. Somebody knows how to do this. So, programming word, we are not able to get it as output unless we type exactly. That we will think about this and tell you later. Anyway, this is not so urgent. We have answered all the questions that were asked. We will just take up one more question from Mufakamja College. We had raised this question long before. That is the question we will take up now. Please ask your question now. In that case, grep minus v. In that file, if I want to have an output file without an element. For example, 2. If I apply grep minus iv and it is remaining, that means that element is present. But I wanted to remove only 2. I want to have remaining total data as output. What to do for that? From what we understand, the question is that when you use v, then it inverts the output. But whether you use v or not, you are interested in the number 2. The number 2 should occur as entire world or it should occur as the number 2. What exactly, how should 2 occur? It is not required for, you please ask this question again. Exactly, whether 2 should occur as a word by itself? One minute, one minute, one minute, please hold on. Please ask. No, actually in my file, I have that element in different rows, more than one rows. For example, 2 element, in more than one rows, that 2 element is present. For that, I am using grep minus iv. For that 2 element. So, what is happening is that 2 rows in which that 2 element is getting deleted, remaining data is getting displayed. I want to have a data without that particular 2. So, you are saying that you want, either you want a line or do not want a line with 2. That is decided by putting using the letter v. But you want the word 2. If you want the word 2, then you are supposed to put before and after the 2, this begin word and end word pattern. Why do not we just see an example here? To Mufah, to Mufah Khamja College, suppose, so let us see this. Now, he is interested in grep 2 marks. It is showing 92, may be minus v. So, he does not shown that particular line, cat marks dot txt. So, maybe if you, now there is this particular 92, that is what we are discussing about. So, if you use, then this 92 is now no longer matching the pattern, that particular line. We do not, we prefer not using row. We prefer saying that line because it is line surge. So, this particular line, is there a pattern with this, which pattern? Is there a, is this pattern there? No. But is this pattern there? Yes. So, I hope this answers the question. So, you please ask now, one minute. Actually, there in the third row what we applied there, that line completely removed, instead of that 67, instead of 2 something empty after that 70, that complete line, instead of 2 without 2, can I have? Ah. See, if you want to remove some pattern inside a line, inside a line, if you want to remove only a particular field, then you have to use cut. Grep is for line surge. The entire line that meets that particular criteria, entire line will be either visible or removed, depending on whether you use a V option or not, depending on whether you are inverting or not. Inside the line, no editing is done. Any line which has that particular pattern will be displayed or removed. Inside the line, no particular editing can be done using grep. You can take the particular output, pass it to cut command and do further things. Take it to cut, but not grep by itself will all modify within a, within a line. Yeah. Okay. I hope that answers the question. Somebody has been, somebody asked whether we can only get the email IDs in file using grep. Yeah, you can get only email IDs. That's possible. You show us a list of the file, then you can use grep. Somebody has asked question on chat whether you can get only email IDs in file using grep. So, this is certainly possible. That pattern, look for a word before or after and get. Okay. Another question that remained answering was how, export. Yeah, export was not, was not addressed. What is e grep and f grep? Somebody has asked what is e grep and f grep? e grep is obsolete. Yeah, e grep is nothing but grep minus e for multiple patterns. f grep I don't remember, that is also obsolete. Whatever can be, whatever used to be possible with f grep is now possible with grep only, perhaps with some options, maybe f option. Yeah, but it is not relevant anymore. These are obsolete and whatever is possible using f grep or e grep is possible with just grep. These commands are not anymore there. It was the best of my understanding. Yeah. Okay. So, now what is export? So, we said already path, echo path. Yeah. So, now you might redefine path equal to something else. Yeah. Does that immediately change? It will change the path, but your searching has not yet started in those directories. For that purpose, you are supposed to export the path. Yeah. So, somebody asked, I think from Kerala, they asked what is export? Yeah. So, for many shell variables, you can define the shell variable and it will immediately have its effect right there. But for certain things like path, for example, there are many others. That path, you can redefine that variable, but that new path will indeed become your path only after you export it. Yeah. So, it is a separate thing that is required only for certain shell variables, especially these shell variables which are affecting the bash environment itself. At least those require this export. I would say to a large extent, there is no harm in exporting all the shell variables. Yeah. Don't worry about deciding is this shell variable finally required to be exported or not. Whether it is required or not, if you go ahead and export it, there is no harm. Yeah. And path happens to be, as he says, it happens to be a variable. You cannot randomly decide it, it will not start searching in those path. You require to export it, then only those, those directories will also be searched for your path. Yeah. So, this particular thing I wrote, this is a new path, echo path. Yeah. You might say, how is this echo command still working? It is not there in this directory. There is no, there is no directory called this. If I change the path, how are my commands still working? Because I have luckily not yet exported it. Yeah. Path is something you don't want to touch too much. Don't, if you touch too much, nothing will go wrong because you have not exported it. Luckily, on this particular batch terminal, path has to be exported. Yeah. Don't try out any random things like I am trying now, because on your terminal may be exporting without exporting already the path becomes a path and all future commands will stop working. You will not even be able to exit. Command also will not be recognized. You will have to go up to the top like this. Unfortunately, and use the mouse and do cross. So, export is required for certain shell variables. They have to be exported only the little work. It is possible that you have to write this in your dot batch RC, etc. There you will see certain variables are already being exported. There is no harm. If you are doing some special work, there is no harm in going at an exporting. My opinion, my impression so far is there is no harm in exporting all other variables also. In path, if you export unnecessarily, the path will stop. So, I don't want to try that now. Otherwise, it will take away much time to again have this terminal. How could we put a particular SH file at present path location? Somebody has asked this question. How can we... So, if you have root permission, then you can put any file in any of this path. If you do not have root permission, then you can only add this inside this. These are within my home. I can make this directories, put my commands there. Then it will always get found. Other files, other directories, we need root permission. For your own person computers, you are the root. So, you can go ahead. You have to use sudo for Ubuntu. You have to use sudo. So, that answers all the questions. How to make shell variable as a constant? All shell variables are never constant. Variables means they can be changed. What shell variable? We should not change. We should leave it for bash to change. That is what we will see next. So, next thing is, instead of test, we can use alias also. So, an example. So, here is an example. So, somebody had asked what are this percent, etc. So, percent is a meta character, just like dollar, hat, open quote, etc. So, percent A and all stand for depending on the context. A here stands for, I think, AM or PM maybe. D here stands for the date. So, these all have some important meaning. Why for year? What meaning they have is best found using mandate. So, this is some shell script we want you to try yourself looking at the screen. Type it in a editor. Editor means nano editor for now. Later on we will see a few basic things about vi editor. But this is what you will type not now afterwards. Why? Because it is very straightforward. Everything that is expected to happen is written in the slide. So, here is a small shell script that will decide. It is a continuation of the previous script. It will decide whether if it is morning, it will say good morning. Whenever you log in, for example, you can make that this shell script runs. And if it is morning, it will tell you good morning. If it is afternoon, it will tell you good afternoon. So, this also you will try later. Why? Because we want to get started with for. How to use for? You might want to do many things over all files in a loop, all variables in some list. So, for is what is to be used for? Looping over a list of files, process all the names for example. For example, I need to use for, for example, when people has spaces inside the file names, all the spaces have to be removed. That time we want to use for write a for loop. Rename all the files from capital small maybe. When you take all the files from windows, maybe that time you they are all capital maybe and we want small. Capital of small, they may be the same in Microsoft windows, but we want them to be small here. Why? Because in Linux, they are all fine lines, all commands, everything is case sensitive. That is when we can use for for a whole of these operations. What is the syntax for that? Simple example, for, this is some dummy thing you can choose. For animal in rat, cat, dog, man. This is some list. This is a list in for every this takes its values inside this list. Whatever you provide this list, this particular variable will take each of these values. Incidentally, we know that this rat, cat, dog, man are all animals and hence we have given this particular variable. We have called it animal. Instead of animal, you can call it a, b, c, an, any, anything, but that variable will take once it will take this, once it will take this, once it will take this until that list is exhausted. For each situation where this variable is equal to this, this, this, do whatever is written between do and done. This is the syntax. The animal word, nothing very special. It is just a variable for our ease of understanding. In, you cannot choose. In has to be in. Whatever this list is, important to note is all elements in this list, when you write it like this are separated by just space. Just space decides one element in that list from another. There is no comma, no more complicated brackets. Do, do this done. After you are done, again go back to for. Do that until you go to the next, next element in that list. So, you can also loop over the list. So, animal is only a dummy variable. Instead of such, such textual words, you can also have numbers. Numbers, you can also write 10, 11, 12, 10, space, 11, space, 12 up to 20. But if you know that these are all the numbers from 10 to 20, you can also use dot dot. Then you have to use curly brackets. If the increment is supposed to be minus 1, then Parash Prashant can tell, separate with dot dots. So, I did not know instead of 10 increasing by 1 up to 20, if you want 20, decreasing by 2, up to 10. Then what to do? Then you are after the 20, use again two dots and put the number minus 2 or plus 2, whatever the increment is supposed to be. Default increment is plus 1. You put that increment again after two dots and then close the curly bracket. That is how, that is what you can do after, after this is something you will execute by yourself after we go to the next slides. Whatever is to be executed is already written very neatly inside this slide. Whatever text is being lost here, do not worry about it. Whatever slides are uploaded on Moodle, they have with smaller font and there it is fitting properly in one slide. The fonts have been made larger upon request for ease of viewing there because of which something is being lost below. But whatever is on Moodle is complete. So, very useful is, as I said for all these file names. If you want to generate that list itself, you do not want to actually see all the files and then copy paste it here. You want to generate it by executing another command. In the context of word count WC, we already saw how to generate a, how to execute some command and give that as input to something else. So, here for i in that list we are generating like this, ls star dot mp3 and we are putting back quotes meaning open quotes which is the key, the open quote that is sitting above the tab key. So, before you actually do this operation best you just echo and see whether it is precisely doing that. Important thing to note in this example is open quote, again open quote. Both between two open quotes whatever is written is executed first and the output of that execution is given as the list for i. And incidentally between consecutive things there is a space. Between all the mp3 files there will be a space. What is space is already there inside some file name. Suppose some file name already has a space, then what do you do? Spaces in names cause trouble as is written here. So, I suggest that you make an example with file name also inside, space also inside the file name and then run this and notice that they will separate into two separate i. In that the list will not be able to distinguish that this space whether it separates to this in that list or whether that space is part of the name of the list, part of the entry of that list. So, there is going to be some trouble there because of which luckily this has been suggested.