 So, welcome back, so we were seeing this cmp command, so hope that you have tried it out using even by copying, making a copy of sample 1.txt, you can even see that it does not produce any output and the prompt returns back, so which means that both files are same indeed same. So, coming to the next command, this is also a series of command in which you want to differentiate between two, whether two files are identical or not, so these are also another command which will, this command is com, which will display what are the lines common to the both, common to both the files. So, the usage will be com followed by file 1 space file 2. Now you can try this on two files sample 5.txt and sample 6.txt that are already present on your system, you can cat first sample 5.txt and sample 6.txt to see that these are just the names of some students or some people, they are some common name. Now when you run this command com sample 5.txt space sample 6.txt, it will produce this kind of output, so what does this mean? This means that the first column means that these two names are only present in first file that is sample 5.txt and are not present in second file sample 6.txt and second column states that these are the only names which are present in sample 6.txt but not present in sample 5.txt and the third column which will tell you what are common to both the files. And one more important thing is here is com, the com command will take the input that should be sorted. We will see what does it mean to sort a file and how do we sort the file after maybe after some time. Just try it out these commands on your machine, so for example you can even change some of the files, if you are present yesterday then you might be knowing how to edit a file using VIM, you can even change the file or any of the files that is bit complicated. You can change the file and to reflect that two other, you can add two names which are identical in both the files and you can see that it will be reflected in the third column of this output of the command. Now this is a description where column 1 gives as I have already said column 1 gives the names which are present in sample 5.txt but not in sample 6.txt that is first file but not in the second file. Column 2 gives the names which are present, which are not present in sample first file but present in the second file. Column 3 gives the names which are present in both the files but mind you this com you will have to give the input in sorted format, all the names should be in sorted format. You will see how to sort the file later within may be quite few minutes. So coming going on to the next commands, these are compressing and archiving files, how do you compress and archive? For example, you might have used in Windows winzip utility which is used for zipping the files archiving the compressing the files and how to even archive the files compress and archive. So we will see how to do it in Linux. So first two commands are gzip and gunzip. So gzip command gzip command is used to compress the file and gunzip is used to decompress or uncompress the file. So the usage will be gzip followed by a file name. So you can give it for example gzip followed by sample 1.txt. So before that try this out wc sample 1.txt try out that and see the statistics of that file that means how many number of lines, how many number of characters, how many number of words are present in that file. Now do run this command gzip sample 1.txt you will get you will get an another file which is sample 1.txt.gz the original file will be replaced with this file and you again try to find out the statistic by using wc and the file name sample 1.txt.gz and you will see that there is like quite a big proportion of number of lines reducing number of characters reducing. So it is the file has been compressed actually can see from this these commands that the file has been actually compressed. Now continuing this so not always the compression ratio that you will get like for example here you had 65 number of lines and you got after compressing 26 number of lines. This ratio may not be same across all the files it all depends on many things like the type of the file size of the file and even the nature of the file like which is what is it like ASCII file or something. So here you have used ASCII file to compress it. So now as you have already seen when you run gzip and sample 1.txt the sample 1.txt file is no more present in your directory. It will be replaced by sample 1.txt.gz that is a new file new compressed file. Now you want to recover the old file run this command again g unzip and then file name with .gz command and you will recover the sample 1.txt file back and again you can try to see the statistic wc and followed by the sample 1.txt just to ensure that whether the decompression algorithm the uncompression algorithm is quite good. So that it gives back you the same file there is no loss of information in compressing and decompressing. So these utilities you can use mainly for sending like for example if there is a huge file you can send using if you want to send as an attachment to somebody through email you can do this. One more thing if you want to compress the whole directory then you can use this option minus r option with gzip. So for example there is a compression directory in that you can try it out this command gzip space hyphen r followed by space then compression the directory compression. So you will get you will see that in the compression directory just cd to the compression directory you will see that all the files in the compression directory are being zipped just try it out these commands on your system using for that compression directory. So I will repeat the command it is same as this gzip you have run gzip sample 1.txt right. So for sample 1.txt instead of file you give the directory with minus hyphen r option gzip space followed by hyphen r option space then compression the directory. So what it will do is it will compress the contents the files which are present in the directory. So you can just go to the directory cd compression you enter the directory and type ls to see that actually the files have been compressed with dot gz format. Now to uncompress it run this the same gzip command with same minus hyphen r option gzip space hyphen r space compression the directory which has been already compressed. So all the files which are present in the directory even the sub-directories it will uncompress the files can try it out and one disadvantage of gzip and gzip that you can already see is that it replaces the original file that is one thing and then the second thing is it does not archive the files. For example the compression directory it created the compressed file inside the directory. So it is not archiving the all the directory sub-directory files into a one file. So we will see how to archive that using the next command called tar. So this is an archival program so tar command is used to create archives that contains group of group or files or entire directory. So it is generally used as a use for backups so generally if you want to take backups on different machines or so you just like it is like a zip in what winzip does in windows but without any compression. So it just archives all the file puts into a one solid file and so that you can easily back up take that back up and then even run the same command and untar the contents of the file. So we will see these are the options which you have actually. So minus c is to create an archive minus x to extract the files from archive minus t to display the files in archive minus f and followed by arc name the archive arc. So for example you can try it out tar space hyphen cvf first you have to specify the file name under which you want to club all those files that is compression dot tar and you specify the directory compression. Now here you have seen this new format of specifying options. So if there are more than one options for any unix command most of the unix command will take you can club the options like this. So instead of minus cvf we can specify minus p hyphen c space hyphen v space hyphen f. So that is more cumbersome to specify. So you can even club all those options together and specify minus hyphen cvf. It says that c which means create an archive v v is for verbose so it will give you the contents of the file which have been archived on the output terminal output and f is to specify the file name archive file name that means you have specified compression dot tar as a file name that is for that is for f v is for verbose which you have seen the output on the terminal and c is for creating archive you are creating an archive you are not extracting an archive you are creating an archive. You can just try this command on the compression directory which is present you have downloaded. So after creating this compression dot tar now you want to know how to decompress it or uncompress it or untar it. So we will see that before that we will be seeing this. So now you have created a tar file which is compression dot tar. So it is nothing but it does not do any compression rather it just clubs all the files together and keeps in one file something like that. Now if you want to do compression on that you can actually run g zip command on the compression dot tar that you have created already. So just run g zip followed by compression dot tar it will create a compression dot tar dot gz file and replacing compression dot tar file. So you have already seen that g zip will replace the original file and it will create a new file. So try it out this command gzip compression dot tar. So it will create compression dot tar dot gz file on your directory in your directory. Hope that you have tried out this command and you can see that it has been compressed compression dot that tar dot gz file is produced. Now for uncompressing it you just follow the reverse procedure you have to first uncompress it using gzip and then final name that is gzip compression dot tar dot gz and then untar the tar. Now for untar the tar and so here you can see minus x-x will extract the files from the archive. So you have to specify tar space-x to archive or to untar the files v for verbose so that you will know what all files will be there it will be outputting on the standard console and f you specify the tar file. I think you have tried it out these commands. Now so if you have a tar file and if you want to just view the contents of the tar file you can see using hyphen t option which is just like this. So if you want to just see the contents of the compression dot tar just type tar space minus hyphen t v f t for just viewing what all files are present in the compression dot tar v for verbose and f to specify the file name and then compression dot tar. So you can just view the files. So as you can already see here we have used two commands first to tar command to tar the files and zip command to gzip command to zip the tar. Now if you want to do the if you want to do all the like both the things at the same time you can do using a special option. So you can directly compress a directory using cv zf and specify the compression dot tar dot gz that is a file name to which file name to which you want to compress and compression the directory that you want to compress. So it will directly what will you do is it will directly make the tar and then run gzip on it and it outputs only one file that is compression dot tar dot gz but then compression directory will be remaining intact. So even you can try this command and for untarring it you can just specify tar hyphen xv zf. So instead of in every in the previous commands we have seen all the options right you have to just specify z more one more flag one more option called z which will tell you if it if x is present you are untarring it if c is present you are creating an archive. So which means that it will run first tar and then gzip command on it and it will give you at last tar tar dot gz file. So just try it on try it out on the systems and so as in you do winzip in use winzip in windows you can use even use zip command to create a dot zip file a compressed file. So it is so like you have used tar with minus z option so it even archives and compress it. So winzip is a kind of utility which archives and also compresses the file. So the syntax will be zip options output dot zip the file name to which you want it the output file name and the files to be zipped or the directory. Now for example zip sample one dot zip and sample one space sample one dot dxt will produce this zipped version of sample one dot dxt. So mind you this command unlike gzip command it does not replace sample one dot dxt. So sample one dot dxt will be present in your directory as well as sample one dot zip will also be sorry sample one dot zip will also be present in your directory. So just try it out this command try out this command hope that you have done with the command and now here you have specified only one file instead you can specified a directory. Now if you want to specify the directory you have to specify the hyphen r option to zip. So zip hyphen r compression dot zip compression will create a compression dot zip version of compression directory. So just try it out this command and also to uncompress it just type unzip followed by the zip file name. So anything like if it is a directory or even a file or anything it will be unzipped and created the file will be created on your directory and in which you have given the command hope that you have completed the command. So you can uncompress any zip file using this simple command unzip followed by the zip file name zip file name. Now these are all the these are all compressing and archiving how do you compress and archive files in Linux. So this can be used by for various reasons like for backup daily backup or anything and for example if the file is very large then you can use even to even zip it or tar it or gzip it and send it across to over the network. Now we will be coming to simple filters. So these are the powerful the Linux is very powerful in so filters are very kind of very powerful tools that Linux has. So we will see some simple filters. Now what are filters? Filters are just commands which accept data from standard input or it can be a file or anything and writes it writes results by manipulating the input to the standard output based on the command that you give the options and all the other things. Now the first command very simple command that we will see is head. Head command displays the top of the file. When used without any option it will display first 10 lines of the file. Just type head space sample 1 dot txt. So on the console or the terminal you have to see first 10 lines of the sample 1 dot txt. Now mind you the line the definition for line will be one which has slash and at the end. So you cannot so maybe you have seen a big line there will be very big lines but then the definition of the line is which ends with a slash and now similarly you can specify even tail. There is another command called tail to see the bottom 10 lines. So without any option if you specify you see the bottom 10 lines of the file that you have specified. Now tail sample 1 dot txt displays the last 10 lines. Now there are many options which are associated with this command tail and head have option called minus hyphen n followed by a number. So for example if you want to see top 20 lines of the file you can specify head hyphen n followed by 20 followed by the file name. So it will display top 20 lines first 20 lines of the file and similarly tail hyphen n 15 sample 1 dot txt or any file name it will display last 15 lines of the file. Tail has some more other options like for example let us say that you are installing some something on the Linux. Now as you have already seen the Linux directory structure is such a way that in slash var you will get all the log messages which means for example if you are doing any installation the log message of that installation will be going on to a file in slash var some directory of the slash var. Now for example you want to know how the installation is progressing. You can use tail command with hyphen f of option. So what it will do is it will wait for the file to be updated and it will show the last 10 lines updated and 10 lines you may be there is no other file here you cannot but if you have any file which is growing you can see that. So tail has that advantage. Now coming to next command called cut this is the most this is one of the powerful commands that you can very easily do anything in Linux with these type of commands. So for example there is a file called students dot txt in your directory just so cut command is basically used to cut the columns of the file. So here if you specify cut minus hyphen c 1, 2, 3, 3 to 5 which means that you want to see first column second column and 3 to 5 columns of the file student dot txt where the definition of column will be a one character. So it will display all the first characters, second characters, third characters, fourth characters of all the lines of student dot txt just type it and just see it. So you may already see that student dot txt is kind of file wherein you have a very structured data kind you have first one and then followed by space followed by a file name and some other data of each every student it is a dummy data but it is a structured data. So then next option that you can see with cut command is you can even cut a field from the file. Now as you have seen it is a structured data and each and every field it is like a database basically. So each and every field is delimited by a character space. So what if if I want to see the first and fourth column delimited by the space in that file called student dot txt. Now I can use this command cut hyphen d in that you have to specify space as a delimiter which means that you take each and every line and cut it into different parts taking space as a delimiter because you have given space as a delimiter and hyphen f followed by the number of columns that you want to view it like one first column and fourth column and followed by the file name. So you will get the output the first column and the fourth column like the mtec or btec the student. So you can even say hyphen f one you can also give the range one hyphen four one to four columns you can view it. So try out different things one comma four will view you only two columns one hyphen four will view we will get you the range of columns from one to four. And this minus hyphen d delimiter we have used here space as a delimiter you can even use some other character as a delimiter like for example colon or a character a character or anything you want as you want. Now coming to another command called paste now paste command it is like it is a vertical variant of what you can say is cat command cat command concatenates to file horizontally like after first file it will concatenate the second file paste command will view the will output the file vertically. So when you type paste followed by cut one cut list one dot ext and cut list two dot ext you will see that both files side by side. So just in order to just view it just type cat cut one cut list one dot ext you will see the file contents of the file cut list one dot ext and then cat the second file you will see the second file contents and then use this command just to view the output side by side. So coming to the next command sort as we have already seen we have seen in one command that is common c o m m command which needs sorted files as a input. So how do you sort the files now sort what does sort do sort does nothing but it reorders reorders the input lines in ASCII sequences with white if there are white spaces then it will it will go up in the hierarchy numerals comes next uppercase then finally comes the lowercase. Now you can even sort the whole file based on a single field like for example in the database you have created a table and you want to order by one column then what do you do you do something like this. So sort hyphen t space which means that you take each and every line with spaces a delimiter and hyphen k 2 which means sort the file students dot ext based on t column second column with taking spaces a delimiter and produce the output on the console. So just try try out this command. So here hyphen t will you will you are telling the system that by providing hyphen t you are telling the delimiter. So here also you can specify any delimiter and there are many other options you can just view for other options just type man sort you will get the whole manual for sort and you can there are numerous numerous options based on like numerical sort you can do it you can do it lexicographic sort you can do it many other things. So just type man and sort you can see it see many many other things. So so this is the last command that we will see today the grep command. So this is the most powerful powerful command wherein for example if you want to search for a specific world or specific pattern in the file if how do you do that. So using grep command you do that. So the usage will be grep options followed by pattern and then file names you can specify more than one file name. So just type in grep then some string like unix or something and followed by sample 1.txt you will see how many lines are there in the sample 1.txt file which have unix keyword appearing in that line. So it will give you the output as line number followed by that line. So even this grep command is like most powerful command there are numerous numerous options that you can explore just type man grep and you will see there are many many other options. So this is like this is like a basic thing that basic line x commands. Now actually you have learned these commands independently. Now for example if what if you want to do club 2 or 3 commands or write a script in order to execute a special purpose. So that will be discussed by Nathan.