Hello, my name is Stephan.
And in this lecture of our course, you will learn about the heat command in Linux.
So let's get started.
So the heat command prints the first lines of a file.
So to print the first four lines of our auxiliary.
With here auxiliary text file with heat, we can use the option n so heat n for.
And four and Oxley here.
And as you can see here, we printed first four lines of our Oxley text file.
So if you request more file more lines than the file contains the heat prints, the full file like keta.
So if you here, let's actually open and as you can see, we have we have six lines here so we write
it like that and.
11, then it will just print the six lines here.
So it will print whole file so he can also read from the STD in four mile pipeline fun.
So a common use is to reduce the output from the another command when you don't care to see all of it.
So like a long directory listing, for example, let's list the first five file names in the bin directory
here.
So or let's actually 15 file names in the bin directory.
So bin hit and it's going to be.
15.
And as you can see, we printed the first 15 lines in the bind directory.
We also have the cut command.
So the cut command prints one or more columns for a file, for example.
Let's actually here.
So.
Let's print all titles from the auxiliary file which appear in the here, for example.
Cut F2 and Oxley here.
And as you can see, we got this here.
So cut provides two ways to define what columns.
So the first is to cut by field F here.
So this f when the input consists of string fields, each separated by a single tab character.
So conveniently, this is exactly the format of a file of Oxley here.
So the preceding cut command prints the second field of each file.
So if we write it like that one here or.
F3 and as you can see here.
So we can also do that like that here.
Here and let's run it again.
And as you can see here, we got a different output.
So to shorten the output, we can also use the pipe it to heat the print only the first three lines
and so on.
So now let's actually use the grep command in our Linux command training here.
So grep is an extremely powerful command, but for now I will hide most of its capabilities and say
it prints the lines that match a given string.
So for example, let's like it here grep.
Oxley and Oxley here.
So Oxley is a text file, so let's actually change it from the UI here.
Oxley dot txt for if you are if some of you are Windows users, you will understand that this is a text
file here.
But for Linux it's actually text files is not stored with a txt file here, so they are just stored
a plain file.
So here oxley dot txt and as you can see here we got all the grabbed all the Oxley here so.
For example, the command displays lines from Oxley that contain the Oxley string here.
So you can also print lines that don't match a given string.
So with the V option here, so grep V, Oxley, oops, Oxley and Oxley dot txt.
This lines here.
As you can see here, we will execute all of the Oxley commands here.
So in general grep is useful for finding text in a collection of files and we can also use command prints,
the lines that contain the string perl in with the names ending here txt for example grep grep, Oxley,
Oxley and txt in a bin here.
So we are not in a bin.
So in this case grep here, let's actually go to bin here cd, cd bin.
We can also write it like that.
Give grep python and txt.
I don't think we're going to have here.
As you can see here, we don't have any python here, so.
And in this case, um, if you have a python here, the grep will fund a matching lines like it did
in the here and print it on the screen.
So we also have the sort command.
So actually let's clear this clear and the sort command reorders the lines of a file into a scanning
order by default.
So you can also change the the scanning or other orders here.
So for example, sort Oxley dot txt and that's not sort here sort.
Sort so you cannot read it.
No such file or directory because we are on a bin directory.
So we're going to go to home here.
Home Kali.
Kali and less clear so sort Oxley dot txt and as you can see here it will sort our file.
So let's actually edit file.
So make it a little more visible like this for example.
Write it.
Apple.
BMW Computer.
A zebra.
Windows Linux and here.
So now we're going to write it like that.
And as you can see, Apple, BMW, Computer, Linux, Windows and lastly Zebra.
So it will write it our lines with it, uh, with ascending order.
So this is by default.
So if you want to change it, uh, like this, for example, sort from the descending order.
So you're going to write it like that are here.
So as you can see here first is Zebra, Windows, Linux, Computer, BMW, and lastly A here, which
is Apple here.
So the sort here can order the lines alphabetically by default or numerically with the N option here.
So for example, if we write like that, it's actually let's write it here numbers or actually let's
write something like 2002, 2023, 2009, 2010, 2015, 2024, 2025 and 1098 here.
So write it like that.
And after that we're going to use the, for example, cut here, cut.
So I will demonstrate this with the pipelines that cut the third field in the animals.
So this here, for example.
In the in this case it's going to six here cut f6 oxalate in the oxalate and as you can see we got this
here so let's actually make it like that cut 1F1 and as you can see, we got an same output here.
So now we're going to use that cut F3 animals, animals dot txt after we're going to sort this with
this and and oops.
Oops, not animals here.
It's going to be Oxley here.
So Oxley TXT and as you can see here, we sorted it within the ascending here.
So the first 98 to 9, ten, 15, 23, 24 and 25, but we actually it quite opposite here.
So we started, we ended with 98 and as you can see here, we ended with top numbers.
But first we rated it with the ascending order here and as you can see here, so we can also write it
the scanning order by adding after end, we can also add R here.
So it will write the scanning order.
And as you can see, first we've written the highest number and then it got two from the highest windows
here.
And as you can see here, this is it.
So if you write like that sort and R Oxley dot txt, it will write exactly the same output like this.
So we also have.
The unique command.
Not unique here.
So unique here.
Just unique.
So this unique command.
The texts repeated a jacking lines in a file.
So by default it it removes the repeat.
So here for example, let's add some lines that has same outputs for example.
I'm here.
Oops.
Let's open.
Yeah, let's add some lines.
So let's add Linux twice or three here, windows here.
Oops.
Here.
So now let's demonstrate here for example, Cat Oxley dot TXT.
And as you can see, we got this here.
So we will use the unique Oxley dot TXT.
And as you can see here, we are not showing the same outputs again and again like this here.
So notice that uniquely use the first three lines to here single in Linux here.
And as you can see here, we got just one Linux, but here we also have two windows, we got one windows
and after that we are just seeing one windows per line.
And after that we are seeing another here.
So we can also use the for example.
Print the gray hour lines with the cut here.
So cut.
Auxiliary text here.
So and we will also that sort.
And here we will use the sort and unique see here sort and are and after that heat here and one and
as you can see we just got five Linux here.