 So, with that we will continue to the next topic, word count is what we just finished. So, we will now see the commands head and tail. So, in this particular directory we have these various files, let us see this bigger. So, first line is about programming pearls, C programming language, mythical man month, some first three lines. Perhaps we are interested in only the first three lines. So, why do not we see just head bigger, it will show us only few lines, is it showing the first three lines only, no it did not know that we wanted we are interested only in three lines why do not we give a option minus n 3 bigger. So, now it has shown us only the first three lines, this fourth line that you see here is a continuation of this line. So, this is just because we have made the font size is very large and hence actually showing only three lines, easier to see for when you use option 2 and shows only two lines. That is very important for example, I will tell you what for those in ITOS we are running this course and when we do partial marking we see each person's code, if the code is completely correct then what we do is we just see that this guy has got full mark because his code has got executed correctly, executed fully correctly is what we can check by using another script. But then for those who are doing partial marking, there for each code we open and see, now do we have to write a pen on paper separate that this person has to get so many marks. No, we wrote it on the first line as a comment, on the first line we wrote this person has got so many marks, this is the reason for not giving full mark, by partial marking we got only half mark 50, 60 percent of the marks for that question, we wrote that in the first line. Then we wrote a batch script that extracts out the first line for every code, for every student's code, that way in one list we have row number code, row number mark, row number mark. So, this is how head command is extremely useful, in one go we can extract out just the first line or just second line, just first ten lines, what about last ten lines, what about tail, last two lines, tail minus n bigger, this extracts out the tail of the file. So, please note these all have to be regular text files, they should not be PDF file or something. Somebody had asked a question about PDF file, how that opens in events etc, we will come back to the question, but please note head, tail, cut, cat, less will all work for plain text files only, these are the only files we will be writing, in basket, latex, python, all these files we will write, just plain text files, to write the files we will use some very simple editors, we will not be using open office etc, even though they are open source, we are going to be using plain text editors about which we will cover tomorrow. So, tail is a command for seeing the last few lines of a file, minus F is also an extremely important option in tail, what is this tail minus F, it will always keep showing the last few lines and it will not come back to the command prompt, notice that here when we did tail minus 2 bigger dot txt, it has shown the last two lines of bigger dot txt and come back to the prompt, this is our command line interface, this is where we are typing on the command, unlike when you do less minus less bigger dot txt, it has showing screen full by screen full, but it is not come back to the command prompt, it is waiting for you to press slash and search for a pattern etc, it has not come to the command prompt importantly. So, now of course, we have gone to the last line and it has said end, it has said end and end we see that last two lines are indeed what tail command was showing. So, if you are interested in only the last line, do we have to each time start less and then go to the end, do we have to really do that and then we have to anyway press a spacebar to come out to the prompt or press Q, so in mind less I have configured that when you press spacebar will come out, also mode you can also configure that as soon as the last screen full is shown, it will come back to the command prompt that is also possible to set in less, but if you are interested in only the last two lines anyway or let us say last 10 lines, tail minus n 10 bigger, so it has shown the last 10 lines. So, what is tail bigger that is also showing some number of lines I think the default is 20, do help tail and it will tell you when you do not give an option minus n something, it has some default number of lines which it will show, if you are interested in a more specific number of lines then minus n that number is what you should be doing, but importantly it has come back to the command prompt, so what is tail minus f now, tail minus f is very useful for monitoring, so it is showing the last this many lines as I said default for something, why do not we see how many lines minus n that is the three lines, sometimes the options have to be given as separate hyphen, so tail minus n 3, last three lines is what we are saying and we are doing minus f and then the file name of course, what is this, let us not come back to the command prompt, why minus f option has made it keep showing the last three lines, what is why keep showing because some other program might append something to the bottom and that time the last three lines might change, we can I will show you how we can while the bigger dot txt file is only being monitored, tail, head, less, cat will never modify a file, it will only read a file, it will keep reading this tail command is used for monitoring, it will keep reading and if you append this file by adding another line, at the same time surprisingly while you are monitoring this file you can go steel filly, you can go from the side to another terminal and modify this file and append some line to this file, let us see what happens, so here you do not have to worry about what I am typing here, this is just to make my prompt a little smaller, now we are going to how do you another line added, the purpose of what I am typing here is only to append another line to that bigger dot txt file, why this particular command is precisely appending another line to bigger dot txt file, this particular result we will see later in this course tomorrow only, so please do not ask doubts about this particular part now, what this does is another line added, this particular line is going to get appended to the end of bigger dot txt, it has successfully done that, let us go back here, look here, so now this new line has got added, so that came because I ended up, I pressed I by mistake, we can append this again, we are steel filly going to another terminal and appending, here it has again changed, so this tail minus f is extremely useful for monitoring a file, regularly going on opening and seeing a line, seeing a file and it is beneficial for that, so how do you quit out of that, because it is sitting and monitoring, we want to come back to the command prompt, control C to interrupt, so this is our notation, control C, please note that this C does not mean capital C, just control C is what you type to interrupt anything, control C for cancel, that C is not capital, this is our notation, allows cut, cut is extremely important command, very useful, you all know cut, paste, copy paste, very important, but then this is not cut using a mouse, this is from the prompt, from the command line, we are going to type a command to cut a particular line, to cut and remove a particular statement, particular column, in every line one particular column is what we will pick, what does this do, so let us take an example, let us see bar, I am looking for an example, let us say marks, so here is an example of some marks, some data files from which we want to copy, we want to cut a particular column, here let us see another example, here are some names, so let us see this marks 1.text, yeah it has marks for example, for each student, these are the various marks of the first student, some name, name might be sitting another file, these are the marks of the second student, marks of the third student, this might be the marks of the first test, you all also will undergo many tests and we are going to store all the information, all the marks not in Microsoft Excel, not even in open office spreadsheet, why because these are just some plain marks, we are going to add them at most, we will save them in plain TXT file, yeah, how to generate that all that we will see soon, but now suppose we are interested in marks only in the third test, first column is first test, second column is second test, third column is third test, we are interested in removing out the marks of only the third test of all the people, so from every line we want to extract out the third column, that is when cut is extremely helpful, what are we going to do, cut minus D, so what does this mean, D, D for D limiter, yeah, how are your various columns separated, they are separated by spaces, how should this cut command know that in your particular data file in your marks 1.txt, you are picking up the third column, third column is specified by minus F3, yeah, but that third column, how are you distinguishing first column, second column, third column, how are these delimited, what is the delimiter, what separates the first and second column, yeah, we know in our file it is space, yeah, and as I said space is very important, after all cut and minus D also has a space, so how do you tell that this has, this is a space literally, in software engineering we had shown that you take double quotes and then immediately the space is taken literally, so here also we will specify cut minus D space minus F3, after you say the delimiter that is when you are able to say third column, with respect to the delimiter first one whatever occurs before the first space is automatically first column, what occurs before the first space is first column, if there is only one space in a line then then automatically two column, yeah, when we do this, yeah, so these, let us check that we have indeed got the third column, what were the marks, cat, we have shown the entire marks one dot txt, this is our third column, third column indeed has come out, yeah, we have cut and removed the third column, this is how we have done that, yeah, we can say not just first, not just third, third and fourth, yeah, it is your third and fourth, yeah, we might say we will cancel off one quiz, yeah, why, because questions are very ambiguous, questions are not written properly, so that quiz should not have been taken into account, we want to remove out that entire column, suppose you, suppose quiz number two was not well drafted, yeah, so we will take only first, third and fourth columns, now, yeah, so this is how, check that it has removed the second column precisely, we might say take second to last, are we supposed to count how many columns and count the last column, no, yeah, if you want everything between in the middle anyway, you can say second dash, that will say second onwards up to the last, yeah, so these all options are certainly there in this, why not we go back to the slides and see, yeah, so cut is extremely important, anybody who has a doubt, please ask right away, yeah, good, there is a question from Bafakam Jha College Hyderabad, please ask your question now. When we give a command minus f, yeah, we can append the line in a particular file. So, our question is that how to, in the tail command, there was this minus f option, minus f option I said was for monitoring a file, so how to save the output or how to save the appended line, anyway that line has got appended to bigger dot txt file, bigger dot txt file is a new file now, which has another line, which another line, the last line is another line added, yeah, the file has already changed, it is already saved there, tail minus f is just showing, it is only monitoring, it is not modifying the file, not editing, it is just showing, yeah, so that answers the question I understand, I guess, okay, please from IMCC Pune, please ask your question. Hello sir, you have directly said it is how to cut and how to get a third column and fourth column, but you did not say how to create that file exactly. Yeah, so the question from IMCC Pune was that we did not even create that file for you, we are going on giving this demos of how to cut, paste all this, you do not have any file to test, there is no file as of now, how will you copy, what cut will you do, yeah, very reasonable question, yeah, so that is why this example here has been, let us go back to the slide, this example here has been showing this ETC password, yeah, see please go to your computer and look at this particular file slash, it is a slash password, do not be concerned, nobody's password is visible there, yeah, in Linux, Unix, no password is anyway written on that, it is not visible, it is stored in some really complicated way, only I think those few developers know how to infer that information, do not worry about it, just go to that line and see that some such long line is there, some very repeated, every line this colon will come, yeah, this colon is separating some two important things, you can use delimiter colon and do it, the slides are drafted far more wisely than how I am teaching, they have kept note that look, users will not have marks 1 dot text file, we will teach you how to do all this, very soon we will learn how to pipe etcetera and create such file systematically, LS minus L we already create some file, you will answer those questions after we take a question from Molina Azad NIT Bhopal, please ask your question now. Gooding sir, I am Dr. Thoma from NIT Bhopal, is it possible to calculate the length of a line in a particular text file? So, the question from MA NIT Bhopal is how do you check the number of characters in a line, just the first line or tenth line, how do you check precisely the tenth line and how many characters are there on a line? As of now I know one method, that is not the shortest method I am sure, there would certainly be good, power more powerful one line codes rather than long long commands. So, we will see that, suppose you will do head minus N1, yeah, of bigger, bigger dot txt, here is this line, here is this line, we have not yet taught you how to pipe it, yeah, but why do not we go ahead and pipe it? This says there are 19 characters on that one line, yeah, it says that whatever was given as the output to WC, that had only one line, then there were two words on that and there were 19 characters. If you, how to use this pipe, we will teach you tomorrow, yeah, please bear with us, we appreciate that you are so curious, you are asking questions which we will cover only tomorrow, thank you very much for this, until tomorrow is all we are asking you to wait, okay. So, any other question, how can we convert text file into PDF, yeah? So, if you write the text file as RST file, then this is a yes, okay. So, one of the questions from SDS, ITSS, how do you, how can we convert text file into PDF? So, let us take, let us continue with cut, but now as a genuine complaint has come that marks 1 dot txt file is not available, let us see this slash ITSS slash password. There is a slash ITSS slash password on every Linux computer. So, there are all these so many, yeah, and this colon is separating everything, this is how it is on my computer. So, what we can do on every line anyway, there is a colon slash ITSS slash password after all generated by the computer, it would definitely have some good syntax. So, why do not we look at second column, second column with what delimiter with the colon delimiter, yeah, we will see second and third. This is a file surely all of you have, output of course will be different because my slash ITSS password is different from yours. So, why do not you all try this, cut minus d colon has to be told to it, if it is not space, if it is colon for example, you do not have to put it in double quotes, yeah, second column of which file not yet told, they all happen to be x, yeah, why do not we take some other, second comma third comma fourth, yeah, some three things have come out, your also will, your output also will be something similar. Now, you can test the various things, yeah, that is the first answer we can give, from second to fourth you can use dash, second comma third comma fourth is same as two dash four, two dash nothing means up to the end, yeah, as many columns as there are. Now, that is as far as using a test file is concerned, but on Moodle there is a test underscore test underscore files dot dz dot zip all zip may all the test files that we will be using again and again. So, we will take a question from KG Someya, Mumbai. So, please ask your question now. Hello sir, as we can use cut command for extracting specific columns, using head we can get the initial rows, tail we can get the bottom rows, is it possible to get specific rows instead of specific columns. So, the question from KG Someya is, cut is useful for getting the fourth column, fifth column, it is all we are worrying so much about columns. What about rows? Suppose you want 10th row, 11th row, you see in Linux in any file any way lines are easier to extract, yeah, lines are, first 10 lines, last 10 lines is what we have anyway done using head, tail, but any 10th line, 10th, 100th, 11th line extracting these lines are anyway easier. They are so easy that is why we already planned to keep it for the exam without covering it. But now that you ask it, let us quickly see it, but then because the extracting out a specific row, specific row means specific line, because they are easier we are not worrying about it as much as column. In my opinion that is an answer. Another question is how to compare two files, we will certainly see this, thank you for this question, but this answers the question of KG Someya, how do you see only the 10th row, 10th row is same as 10th line, so that is not difficult to see, so let us see it quickly. So, another question is how to redirect the output of one terminal, output of the command of one terminal to another terminal. So, another terminal is a little hard to the as input to another command is easy, how to save it to another file is certainly easy, which can be read from another terminal, one terminal to another perhaps is possible, hard to say anything is impossible. So, let us see how to see the 10th line, let us see this bigger, there is a bigger file, rather big file. Suppose you want to see first 10 lines, head minus n 10, it is showing a 10th first 10 lines, if you want to see the 10th line, only the 10th line if you want to see, are you forced to see always see the first 9 lines also, why do not we, so after you see pipe, this is showing only the 10th line, the important thing for you to notice, there is a pipe, pipe means what, pipe is happens on most keyboard it happens to be just above the enter key. So, if you use pipe, then you can do all this easier, you can also do this using something called said s c d, this is something I kept only recently, if you use s c d, then you can directly get you can print only the 10th line, so s c d something will not cover, but piping one thing output of one thing into as input to another is something will cover, certainly cover for those who are really curious about this, we welcome the curiosity, please go through the slides and already the answer will be visible, it is explained in the slide, this is another question, how to cut the row from a text file, how to remove out a text file, this is also doable, this is also doable, one of the questions is from V I T Vellor, V I T V is Vellor, one of the questions from Vellor is how to cut the row from a text file, how to remove only the 10th line, 10th line perhaps is because some particular guy has got very low marks and we are interested in sending the entire marks file to everybody and we do not want everybody to know that this guy has got very low marks, we will just cut out that line, it is not hard to do it, what to do is just get the line numbers and remove out that line which starts from 10, this is something we will do when we see grep, grep is a command from general regular expression command which we will use and then you can see, you can cut out, you can print all except 10th line, you can print only the 10th line also, all that is very easily possible using grep. So, with this we will go to some more advanced things within cut, so cut allows choosing on the basis of characters also, if you are interested in cutting out just the 4 characters, not using a delimiter, they are all sort of every character location is known and you can also use this, dash 4 means what, everything up to 4, 10 dash means what, 10 onwards up to the end of that line, so the default is for every line, so for now paste, very important, paste after you cut we will also like to paste it, paste takes one line of that, one line of this and appends them line wise, on the same line two things will come, so this particular line that is shown here, is shown only for demonstration, it will not actually get generated by using paste, so please note that this line is not generated, paste will do it will get this students.txt, marks.txt and it will put this two lines, two lines from two different files on the same line of the output, this is what we will see, paste students.txt, marks.txt, why because one person might be generating the marks, one person might be writing the students, in many universities, in many colleges, it is a very nice policies followed where, the person who is checking, there is some coding going on, the each person will write only the code number and mark, code number mark without knowing the names. Finally that some big person has to combine the two files, how is this combining going to be done, for such a simple task are we going to open spreadsheet, we will not open Microsoft spreadsheet, but are we going to open open office spreadsheet for such a simple task, so paste is the command to do, what does the space do, for this we need the example files, so you can try out this example after downloading test underscore files.zip later on after this session is over, so please pay attention to what is being done here now, so there are students here, then there are marks, sorry, these are two files, luckily continuing the same number of lines, each has five lines, now we want to say first line here corresponds to Hussein's marks, next line, sorry next line here, this line here corresponds to Dilbert's marks, in other words we want to paste this beside each other, why do not we just do paste, paste students mark, it has put this on the screen, it has shown is on the screen, if you want to save this to a file what to do we will very soon, but is this output acceptable, is this what we really voted, so these were the two files and at least the last line is indeed visible, when output it has got pasted like this and last line indeed was, last line was indeed Sven here and last set of marks last line was equal to this, they have come beside each other, that is the tougher part of the work, at least whatever is required has come correctly on the screen, it has come on what we call standard output, standard output is a screen, whatever is supposed to happen has happened, but it has come on the screen, so this standard output now to get it to go into a file is a easier task, that is the next thing we will do, let us see if there is anything more to do in paste, let us go back to the slides, so is the first column of marks file had roll number, so one can try some more advanced things to print, so paste will just paste the first column here, first file, second file and put the line by line, it says minus s option will print one line of this below the first line of that, line by one you may not want to append everything on the same line, minus s is an option for doing as it says one below the other, which one below which, the sequence you can check that the sequence in which you give the arguments is important, paste command requires two arguments, two input arguments, one file another file, of course you can take three, four more files also, at least two are required, so we already saw the output of paste command, it came on the screen, how to make this go into another file, that is the next important thing, this for this we will use this greater than sign, extremely important in batch scripts, whatever output you check that it is coming on the screen correctly, once you are sure it is coming on the screen correctly, you will redirect it, greater than sign means redirected to something else, redirected to a file, this greater than is almost suggestive of an arrow, it will get arrowed, it will get redirected to file output of paste, use any file name, it is just suggestive for the purpose of explaining, so now nothing has come on the screen, standard whatever had come on standard output has got redirected to file output, some long underscore, some file name we gave, are we sure it has done that, why do not we do cat, so I encourage all of you to be very suspicious of any claim that I do, suspicious of any claim written in the slides, always tested, we already know how to check the contents of a file, cat, luckily it is exactly that, what if we do it again, it will overwrite that file, here there is no minus i option, it will know you cannot make an interactive mode, do you really want to overwrite or not, all these possibilities there only for cp, mv, some such command, when it comes to this greater than sign, it expects that you are all very responsible, overwrite is default, you cannot even disable that, overwriting is no, it will happen, what it will allow is, it will allow you to append to this, if the file already exists well and good, otherwise it will, if the file exists, it will append to that file, if the file does not exist, then it will create that file, this particular double arrow means, now we can check, so it has that same output has got created two times, first time of course it created the file up to here, after this much was created, again the same output, incidentally it was same, in general it could be different, same output got appended to that existing file, so double arrow means append, double arrow will also create the file, if it does not exist, single arrow will create the file, if the file already exists, it will overwrite, certainly there is no way to disable it, please use this very, very carefully, so we know that how output of this paste, default output comes on the screen, screen means monitor means standard output, STD OUT, in various commands you will see that the output goes to STD OUT, all capital, let us see if it is supposed to be a shell variable, let us see what it does, there is no variable in it, but this STD OUT means standard output, that is default the monitor, if you do not want the output to come to the standard output, you can use greater than sign, that will direct it to the, direct it to a file, double arrow mark means it will append it to that file, if that file exists, if that file does not exist, it will still create that file, so now let us come to some more command shell features, so we will see the use of the pipe command, so redirect we have already seen, pipe is an extremely important thing that we will see now, so cat, this is the output, suppose this output whatever has come on the screen, whatever has come on the screen in general, from this screen we want to, we want to run another command, for example, we want to remove the second column, we want to remove the second column from where, why do not we do this, so we already saw the paste command, that is why we are doing this, notice that there is no greater than sign, maybe we are doing all this operations, sitting in somebody, in some directory where we do not have write permissions, so it comes on the screen that much, because we have read permission, we can paste these two files and output of the paste is coming on the screen, coming on the screen we do not need any permission, there is no ch mode or anything required for showing the output of some command on the screen, but maybe we want to run some further operation on this, maybe from this we want to extract out this particular column, if you want to extract out this particular column or we want to extract out only the first column, so ideally we would like to use cut, cut minus D minus F1, so let me just extract and explain what this is doing, so please see only this part now, how does this part work, cut delimiter space, once you have decided the delimiter all the columns are well defined, now you have to say first column, after that how did the cut command work, it required the file name, I mean if you want to use cut command, you are supposed to say the file name over which is supposed to act, but now we did not specify any file name, but still it has worked, how did that happen, whatever file name it is supposed to take, that has been fed in from the back door entry, that is like pipe, so let us call it dash, dash is not a file actually, it will help later on when we use paste, it will certainly help there, so actually there was we did not specify file name, if you did not specify anything, but you are giving that information, how are we giving that information, that one is coming from here, so please pay lot of attention to this part, pipe, redirect, extremely important, the role that this dash plays, you will also become very important very soon, so just note that we did not specify any file name to the cut command, delimiter, first column all that we have specified, but we did specify the file name, why because that is coming as output of another command and that output instead of going to standard output, instead of going into a file, instead of being redirected to a file, it is being carefully piped to the cut command, I am not sure what is the best analogy for the pipe usage of the pipe symbol, it is like somebody is ill, some small dog is ill and it is not taking food, then you put a pipe and send the input to that mouth directly through a pipe, think of it like that, as of now there is no better analogy, so the input argument, the file whatever supposed to come from the file to the cut part of the command is coming through this pipe, earlier for earlier keyboards, the pipe symbol had a small space in the middle, that time it was very clear that there is a hole between it through which the information comes, but then for modern keyboards somehow that part of the small hole inside that pipe is missing, anyway the pipe still works exactly like a pipe, so of course there is only one cut requires only one file name as an argument, so there is no dash required to be given, so this is something each one of you should check, on which file just take cat slash utc slash password, such a big file, now pipe it, whatever has come on the screen pipe it to cut, cut minus d colon and which column minus f2, sorry f, f I forgot. Why do not we say only first column, so this cut underscore d, cut space d colon, this part of the command does not even have to know how that input, input to this cut was generated, it happened to come from a file by cat command, but that is besides the point, this is just an example, it is coming through a pipe, that is all that matters for cut, is this clear, we have to take questions on this now, MES, good there is a question from Kolhapur, please ask a question now. You just shown as the command PEST, PEST then student dot txt, marks dot txt, we redirected the output using the pipe to cut hypen d, then in the double code space hypen f, but I tried the command with hypen f, space 1 comma 2, then it is not showing the proper output, the columns are not getting merged properly. So, the question from Kolhapur is that I as an instructor chose to take only one column, but if you take 1, 2 or 3 more columns, then this column formatting is not working properly and I knew it will not work properly, that is why I took only 1 column, good that you try to take more columns and you indeed saw it is not working properly. So, we will have to discuss a little more in detail, are there any other questions meanwhile? So, why do not we have a question from Nirmai University Ahmadabad. So, meanwhile we will have the question from her, yeah, Nirmai's question who is sitting here, who is not using a mic. So, let me repeat the question, her question is we use a greater than sign for redirect that could have been used by cat for cat command also for concatenating multiple files, after concatenating multiple files instead of the output coming on the screen, we could redirect that to a file, yeah, certainly that is exactly what I had used in the beginning when we wanted a bigger file because we wanted to see the use of the less command for that purpose we had used greater than sign. So, concatenate actually works for that, just for convenience default cat commands output is coming on the screen, it is most often used to concatenate them and convert it to a file, yeah. So, thank you indeed, we will take this question from St. Joseph College Kerala. Sir, how to print multiple only selected lines in a file? So, the question from St. Joseph Kerala is how to choose and print only the 10th, 12th, 100th lines, only few lines not all the lines, yeah, how to choose and print precisely those lines. So, this is possible, I already showed one example, if it is only one line then you can use a combination of head, tail and pipe, but then you can also use grep to do this, as soon as we do grep in case I do not, in case I forget to address this question, please remind me, yeah. Immediately after grep is when we can certainly do this, we can do what? See only precisely some 4, 5 lines which may not be consecutive, yeah, that is what we can see immediately after we see grep, okay. So, meanwhile we can go to Nirmah University Ahmadabad. Right, how can we cut a particular row using the cut command, like we are cutting down the columns, right? How can we cut rows from a file? Yeah, many people are asking how to cut only the first row, second row, how to remove it? This seems to be very urgent, we will do it right away, yeah. So, our question is, we saw how to cut and remove only the fourth column based on a particular delimiter, but we would like to know how to cut the tenth row, yeah, tenth row means tenth line, yeah. I should say these are easier, that is why we have not covered it, but they are important, they are certainly more important than cutting a column. So, we will see that how to cut the last 2 columns, okay. So, let us see how to cut this. So, first question was, first important question that we did not answer was, somebody wanted to see first and second column for this particular command here, not for this, but for here when that person pressed 1, 2, then it has gone wrong, yeah. This is because there are many spaces, yeah. Each space is considered, see in this and there must be one space here, then there must be another space here, because of while here there is no space, yeah. Some multiple spaces are causing this to go wrong, yeah. On the screen what we are not able to see is space and tab look the same, yeah, but if there indeed had been precisely one space, whenever you see many spaces, you do not know whether there are multiple spaces indeed or look at this, this is what is coming on the screen, we have interchanged the sequence. Now, there is nicely exactly one space, yeah. Now that there is exactly one space, why do not we do first and second column for this output, this is better formatted output. Space is a extremely dangerous thing to use as a delimiter, yeah. It is good only if you know every line, every column, whenever there is a space there is only one space. If there are multiple spaces like it was there in the previous case, then there is a problem. So, here again the output will be fine, yeah. Here if you use 1 dash 3, it will work. Why? Because we know that this is exactly one space, but do we know, but this part is exactly one space, maybe there are two spaces, three spaces, maybe at the end of this line, inside the marks dot txt at the end of that line, there might have been many spaces, end of the line, some extra spaces, they are harmless. Somebody might have put many spaces, spaces anyway we cannot see, yeah. That is why something is going wrong, yeah. So, if you, so here there may be some spaces here, some, yeah it is hard to see on the screen, yeah. So, please use the space as a delimiter very carefully. In our own organization of the data, we always use semicolon, yeah. Semicolon is hardly used for anything else, colon, semicolon are better delimiters because they are always visible whenever they are there, they are visible. Space is this invisible character, how many spaces are there are not visible, that is one question. Another question was how do you check only the tenth line, how do you cut out the tenth line? Yeah, so let us see this marks, marks is primes. Let us look at this, there are many lines here, these lines are not numbered, yeah. So, why do not we say grep, grep is something we will certainly see tomorrow, please allow me to be a little fast today, yeah. Let us see, so grep, pattern, pattern 2, how do you use grep, pattern to search in items.txt, yeah. Is there any, there is no word pattern to search in items.txt, that is why nothing has come out. Surely begin line character will be there, yeah. Begin line character is hat, that is why it has shown all the lines. Why do not we try to show all these with line numbers also, yeah. So, now all line numbers have come on the screen, yeah. So, believe me do not feel this too hard, tomorrow only we will see the advanced usage of grep, all this will cover tomorrow. Now that this has come on the screen, why do not we grep for the 10th line, how do you look for the 10th line, one way is to just put this 10, but this 10 might have occurred inside some line, yeah. Genuinely inside some line that may or may not come, luckily no line had 10, but one should ideally be careful and say 10 should occur in the beginning of the line, yeah. This has come, this is how you can extract out the 10th line. This has come as output, but you may not want the number 10 in the output. How will you do this? Why do not we pipe it to cut, yeah. Cut minus delimiter, what delimiter colon, yeah and then minus F to onwards. This has shown the 10th line without showing the number 10, yeah. Only because many of you ask this doubt, we have done it now. Do not worry, this is just one of the various ways. If you know pipe, if you know cut, grep is anything, anyway we will teach you tomorrow, you can do using this. SED is something, some streamline editor which will do this even easily, but we are not planning to cover that in the course, in this course, yeah. By just careful combination of pipes, it is possible to do this very, very easily. By just using each time output of this, you pipe it to again another command, which will look for something whose output can be sent to another pipe, yeah. See output of this is being piped to this command, output of this command is being piped to cut command and the final output is coming out precisely as the 10th line, yeah. The number 10 has been put in here. What is this doing? It is putting line numbers to every line, yeah. Finally, output we do not want that number 10 to be sitting in a line, yeah. Is that okay? Does it answer the doubts of so many people? Okay, let us look at this. Somebody from Afakhamda College has asked, I am having two files, two file names. First one consists of five columns, second three columns. I want to cut the second column in the first and paste it in the third column in the second file. Is it possible? It is impossible that we will say no. If it is not possible, if we do not know now, we will look it up, but all these are very much possible, yeah, by using plain commands. So, let us see, but in order to do this, we have to understand paste a little more, yeah. We, in particular we have to understand what was the dash we had used, the dash that we had used and we said it is optional for a particular case. That is no longer optional now, yeah. When we are using paste, we have two input arguments. So, why do not we see this slide? Redirection and piping. This particular doubt that has been asked on chat will get answered very soon. Cut minus d space minus f2 dash marks 1 dot txt. What is this slash? This slash is just to allow you to continue to write on the next line, yeah. When that line becomes very long, then we want to be able to continue to type on the next line without pressing the enter command. If you press the enter command, it will get executed, yeah. Now, you want to press the enter command, but not executed. So, please type slash, backslash I think and then press the enter command. Then you can continue to type that command here, yeah. With a smaller font, of course, the entire thing can be typed on the same line. You can try to do that also. What does this do? Paste, you have cut out some marks from the marks 1 dot txt, second to last column we have cut out using some delimiter and the output we have put to some temporary file. Temporary file we have hence copied in some temp directory. Temp is some directory that is then on all Linux computers where several such junk temp files automatically generated are all put there. Now, then what we can do? We can paste students here and the temporary file. This particular doubt somebody had asked on the chat is exactly like this. Now, instead of doing all that, why do not we use pipe? Pipe is being used. So, the output instead of being redirected to this file is being piped, piped to the paste command. After all, this was generated only for paste. There is no other purpose of this. Some temporary file because you did not know where to keep that standard output. So, you wrote it to temp, some file there. Now, this paste unfortunately paste whenever you want to paste one file another file you need two files, yeah paste request two arguments. These are all options. One argument is coming from a file. Second argument where is it coming? It is being piped, yeah. Now, paste you have to tell whatever is being piped is it the first argument or second argument for the paste command? For the paste command two input arguments, two file names are required. One of them has been avoided carefully because of the pipe. The other one is provided from the file itself. In paste as I said if you interchange the sequence of files, then it will, it will paste the other way. So, you have to, this dash is playing a very key role here because there are two input, two file arguments to be given. Dash will tell you whatever is being piped it will serve as a first file argument or second file argument, yeah. So, the first one first solution uses redirection, second solution uses piping. So, whoever has asked this question I strongly encourage you to try this using paste. One of them perhaps has to be written into a file whether one of them can be avoided or not is something I will check up and tell. It might be hard but it might be possible, yeah. So, dash is playing a role for that. We will just quickly take a question from ANCC Pune. Yeah, please ask. Can we use the cut command for cutting the columns and changing the sequence? Like for example, there is a ten column, ten columns are there and I want to cut the column number three, column number one, column number five in the same sequence. Will it be possible to display in that format? If I understand the question is you take a file cut only the first, third and fifth columns and it will be shown on the screen. That is what it will certainly do. No, no, no, no. I want to cut the column number one, third and five but it suppose in the, I want to change the sequence. I want to display the column number five first then one and then three. So, if you want to interchange the sequence of columns, see there is only one buffer, yeah. There is whatever, whatever can be piped, it is like a buffer. There is only one buffer. Now, you have one, three, five. What is, if there are, if you are not, if the delimiter is not a space, then this is a easier thing to do. If the delimiter is not a space, if it is colon for example, best is to paste it, yeah. Best is to paste it. Actually, I tried it but for example, if you, if you, when you, when you do the cut command and if you specify the column, if you specify the column five comma one comma three, if you, if you put, if you put the command like column, in the column we can put five comma one comma three. It will cut this three column but it will display in one three five. Yeah, yeah. So, you cannot change the display sequence. Sure, sure. So, yeah, thank you indeed for checking this. So, so the question from INCC Pune is another command. You mean, no, the challenge is using cut, paste, pipe, we should do it. That is possible. Yeah, it just requires, are there any other questions before we do this question in little more detail? Are there any other questions? No. Okay, thank you. So, the question from INCC Pune is that you want to interchange two columns. How to do that? Yeah, if you can interchange, you can do many other things. So, let us just look at marks. So, here are four columns. So, what he only tried was minus D minus F. Suppose he wants only first and third column, not just that, first and third columns have to be displayed as third column first and then first column. Yeah, one very obvious good thing to check is, you put 3 comma 1. Of what file name I forgot, marks. So, it has shown first and third column only. So, what sequence you put these numbers does not matter. Yeah, that is the first thing we can note. Why do not we do like this? Why do not we pipe it, paste, paste to what? Marks 1 dot txt and D minus 3 comma 1. So, that is the dash. So, let us put some additional things. Yeah, now we can also actually we can interchange this as soon as we put the dash here. So, at least whatever you wanted, you can, you are able to put it earlier. For example, if you wanted the third column to come first, you can do it like this. Yeah, and now that now is when you can take first and second column of the output. Of the output, if you take the first and second column, the space is potentially a problem, but why do not we cut minus D? Yeah, so 1 comma 2, so these are tab delimited. Yeah, this has shown the first and third. Yeah, this is what was wanted. This is the third and first column of this file. Yeah, but why have we put only one here? Because as I said, this particular strange character is not space. It is the tab character. Yeah, they are invisible and very, very, very, it is leading. Yeah, because it is tab character, we do not understand whether it is space or tab. So, just first column happened to be enough. So, this was indeed the first and third column of the original file. Yeah, if it is, if it is space, then there is a problem as I said, but this, a careful combination of these can be used to interchange the sequence. So, Prasanth, the way here who will help much later on in this course also, has told me just now that when you use paste, default paste is going to put the tab character at the end of each line of the first file, of the first file, tab character is going to be put. Yeah, if you do not want tab character, but you want the space character to be put, then paste with some addition options will help you do this. So, please see help paste for this, then the space will cause less of a problem. Of course, luckily the space was not a problem in this file to begin with. That is also required. Yeah, this is how one can interchange the first and third columns. First, third and fifth also repeatedly one can do like this again, again. Yeah, any other questions? Before we see a little more in detail about the redirection and piping. So, redirection, standard output. Stream goes to the display, that is a default as I was saying, not always what we need. So, the first solution redirects outputs to a file. That is a greater than sign. Yeah, double greater than sign as I said happens to the specified location. If the file is not, it does not exist, it will create it. Whatever standard input, standard input is the keyboard. Default whatever we are supposed to type is supposed to come from the keyboard. You can make it come from a file for certain for certain commands like cut, like paste. They all have to come from a file, but there are certain other commands for which this input is supposed to come from the keyboard. Instead of coming from the keyboard, you can use this other symbol. It is less than. Yeah, that I am all the commands that you are supposed to put in from the keyboard will come from the file one. What is supposed to be in file one? Whatever you are supposed to type, the standard input instead of coming from the keyboard will come from the file one command. So, there are there is also third one called standard error. Yeah, for many commands you want to know whether there is an error or not. Yeah, especially when we are writing batch scripts to check your scripts. That time we want to have a count whether there is a error or not in the execution. Why this is required? Otherwise, you might have an infinite loop and our program will not exit out of our checking process because your program is not running properly. So, that is when standard error is also really important. This also can be seen in detail. So, this is something we already saw. Yeah, so the first one greater than means standard output, two greater than means the standard error will go to this particular file. Yeah, one greater than means the standard output is getting directed to that particular file. Whatever file you write here. Yeah, default means what? Typically we are interested in just the output, not much in the error. At least in so many years now I have never been interested in the error. But now for the batch script checking Srikant, Prashant are also paying attention to that. So, this is a symbol for that. Two greater than means standard error. Piping is also something we have already been seeing. This vertical line is called a pipe, tab completion. So, we already saw this. So, tab extremely useful for completing something. Use tab as far as possible use tab. That way spelling mistakes will not occur. If you know a file exists and tab is not completing it means you have already made a mistake in the spelling. Yeah, two times means it will list all the possibilities because there is an ambiguity it has not completed. Then it list the possibilities. You can resolve the possibility by typing as one letter more and then typing the tab command. The tab will complete different things. So, if you have only typed the command and the file name is to be typed, then tab will complete the file name. If it is supposed to be if it is a CD for a CD command, CD what is the input argument to the CD command? You will not change directory into a file. You will change directory only into a directory. So, it will tab will automatically complete only two directory names. If it is a command you want to execute, then it will look for only executable file names and also all the commands that are available. If you tilde, tilde is one thing that we did not spend much time, we will just quickly see that now. Tilda will try to complete to all possible user names on that computer. Host names, the at, where are the host names, this also we can spend a few minutes now. Variable name, dollar we already saw this. We saw home variable, we saw old PWD variable, also PWD variable we saw, history. So, we will just quickly see all these different users, etc. Look, there is only one directory, test directory. If you try to change the directory, this is the only possibility. Is this really the only possibility? Can there be, there are two more possibilities. A CD from here can have also CD dot dot. Let us see what happened. Default, it is not trying to do CD dot dot nor is it doing CD dot. Of course, you can also directly go to another directory which is absolute path name. That also is not default you do, it will complete only test directory. That is not always the case. For example, another command for cat. After cat, you are supposed to give a file name. Which file name do you want to give? We have not decided yet. Why do not you press tab? Tab 1, nothing has happened. Another one, it has given all these potential completions. Amongst these, we are supposed to resolve this conflict now. If there are more, it is not one screen full. Why do not we type P? After P we complete, it is completing to primes. Starting from P, there is only one completion. Luckily, if there are more completions, for example, M. From M, there are up to marks, there is only one completion, but then from there on there is one marks 1 dot txt or marks dot txt. We can resolve this by typing only one letter. Why do not we just type 1 and then press tab again. Now, it is completed. That is as far as cat command is concerned. But for CD, let us come back to CD. CD, you are supposed to give a directory name. So, clearly marks you type and we know there is a marks 1 dot txt, but for CD command it will not work. For CD, you just type tab, only one test directory is the only directory in that particular current directory. Whatever executable names, so you might have a file name. For example, grep gre. After gre command, you already use a grep command. Why do not we press tab? So, P we did not have to press. Why? Because starting from gre, there is only one. Why do not we see from gre? From gre, there are so many commands. At the command, when you are typing a command, before you type the space, there are many completions. All these commands are potential completions. So, why do not we type one more? We see that if you type P, there are some commands. So, now if you type P, then there are only this many more completions. If you type U, then the ambiguity will be resolved fully. I type U and that is how this happens. Now, what about user names? Who are all the users here? So, why do not we go to CD? Tilda means home. Tilda means home or whom now? Who is home? When I say I am going home, just Tilda means going home. It means my home. We are in this home, but we could also be interested in some other home. F, we already saw that Fossi is a directory. He is a user name. So, F and then, it is not completing. So, not for CD or something else it might. So, it is a finger. So, where is this user name relevant? So, for finger, finger is not installed. So, finger used to be a command. What am I thinking about? In the slides, there is some user names. So, executable names, I have given you an example. Directory names, I have given you an example. I am trying to look for an example where tilde you type and type tab, it will try to complete user name. For that, I have to think of a command which requires user names as its argument. So, which command requires user name as its argument? Finger, for those who used to know finger, finger used to be an example of a command. You can finger some person and see when the person asks login. You can see many others information. That person's phone number, some such useful information if he has kept, that is also available on finger. But nowadays for security reasons that is being removed. That is why finger is also not there in the default installation. Finger can be installed of course. Host names. Host names are typically with at. Why? Because you use a user at, so and so, host name. Like login names, user at, so and so, email address dot com. So, host names is what we can see. For user names, I should look for a good example. So, why do not we see host names? Why do not we do SSH? SSH is command for secure shell login into another server. Bellore at, Bellore at so many servers. These are the various servers that are there in the database of this computer. We type at, after at when we press tab, there are so many servers. Why do not I say Bherav? Just B, completion is Bherav. Why? Because B is the only completion according to the list of hosts. Where is this list now? Incidentally, I happen to know this because I have to typically. So, these are all the various hosts. Listed in slash etc slash host. This would be there on everybody's computer. All these various hosts is what it is trying to complete. After you put at, why at? Because when you do SSH, SSH typically requires all these server names, all other server names into which we could do secure shell login from our computer. So, at is an example for that. What about variable names? Echo. After dollar, there are many variables you can complete. We already saw H. From starting from H, home is not the only one. Just because we saw home variable does not mean there is only variable starting with H. So, from echo. Echo is a command for echoing out various things. Echo can be used also for seeing the value of a particular shell variable. So, H O. Now, again home is not the unique completion. You can type host name. Home anyway you all know. That is the name of this particular computer. You can also see host type. It is some I 3, I 6, 8, 6. Parasitism, processor number or something. So, these are the, this Linux kernel number. So, these are the different completions. You can also see echo. All the shell, this is something I encourage you all to do. There are, if the number of completions is too many, then it will say there are 108 possibilities. Are you sure all of them should be displayed? Just pressing yes will display them. These are all the various shell variables. You can see that echo user, user name is also a shell variable. These are the different shell variables. Tab completion after you put a dollar will automatically try to complete two shell variables. After dollar, shell variable is what most likely you are interested in and hence tab completion will work for that purpose. So, tab completion is a good place for us to stop. Shell variables is what we have seen. The next topic is again a very important topic which will require a good amount of time. We will complete, we will continue from history tomorrow morning at sharp 9 a.m. Thank you very much. Questions also on all the topics we will start taking tomorrow morning. Thank you.