WEBVTT

00:00.710 --> 00:01.880
Hello, my name is Stephan.

00:01.880 --> 00:06.470
And in this lecture of our course, you will learn about the heat command in Linux.

00:06.470 --> 00:07.880
So let's get started.

00:20.970 --> 00:25.370
So the heat command prints the first lines of a file.

00:25.380 --> 00:29.700
So to print the first four lines of our auxiliary.

00:30.540 --> 00:37.650
With here auxiliary text file with heat, we can use the option n so heat n for.

00:39.170 --> 00:41.870
And four and Oxley here.

00:42.080 --> 00:46.790
And as you can see here, we printed first four lines of our Oxley text file.

00:46.790 --> 00:54.940
So if you request more file more lines than the file contains the heat prints, the full file like keta.

00:54.950 --> 01:02.210
So if you here, let's actually open and as you can see, we have we have six lines here so we write

01:02.210 --> 01:03.950
it like that and.

01:04.740 --> 01:09.000
11, then it will just print the six lines here.

01:09.000 --> 01:17.330
So it will print whole file so he can also read from the STD in four mile pipeline fun.

01:17.340 --> 01:24.840
So a common use is to reduce the output from the another command when you don't care to see all of it.

01:24.840 --> 01:33.450
So like a long directory listing, for example, let's list the first five file names in the bin directory

01:33.450 --> 01:33.660
here.

01:33.660 --> 01:38.070
So or let's actually 15 file names in the bin directory.

01:38.070 --> 01:42.120
So bin hit and it's going to be.

01:42.910 --> 01:43.600
15.

01:43.600 --> 01:48.250
And as you can see, we printed the first 15 lines in the bind directory.

01:48.280 --> 01:51.000
We also have the cut command.

01:51.010 --> 01:56.020
So the cut command prints one or more columns for a file, for example.

01:56.410 --> 01:57.220
Let's actually here.

01:57.220 --> 01:57.820
So.

01:58.650 --> 02:06.270
Let's print all titles from the auxiliary file which appear in the here, for example.

02:06.870 --> 02:11.010
Cut F2 and Oxley here.

02:11.010 --> 02:13.200
And as you can see, we got this here.

02:13.200 --> 02:17.630
So cut provides two ways to define what columns.

02:17.640 --> 02:21.720
So the first is to cut by field F here.

02:21.720 --> 02:28.500
So this f when the input consists of string fields, each separated by a single tab character.

02:28.500 --> 02:34.170
So conveniently, this is exactly the format of a file of Oxley here.

02:34.170 --> 02:39.810
So the preceding cut command prints the second field of each file.

02:39.810 --> 02:43.710
So if we write it like that one here or.

02:45.260 --> 02:48.440
F3 and as you can see here.

02:48.440 --> 02:50.690
So we can also do that like that here.

02:52.410 --> 02:54.460
Here and let's run it again.

02:54.480 --> 02:59.610
And as you can see here, we got a different output.

02:59.850 --> 03:08.910
So to shorten the output, we can also use the pipe it to heat the print only the first three lines

03:08.910 --> 03:10.860
and so on.

03:10.860 --> 03:17.760
So now let's actually use the grep command in our Linux command training here.

03:17.760 --> 03:24.270
So grep is an extremely powerful command, but for now I will hide most of its capabilities and say

03:24.270 --> 03:27.660
it prints the lines that match a given string.

03:27.660 --> 03:32.010
So for example, let's like it here grep.

03:33.550 --> 03:36.550
Oxley and Oxley here.

03:36.550 --> 03:41.020
So Oxley is a text file, so let's actually change it from the UI here.

03:41.050 --> 03:47.590
Oxley dot txt for if you are if some of you are Windows users, you will understand that this is a text

03:47.590 --> 03:48.340
file here.

03:48.340 --> 03:53.940
But for Linux it's actually text files is not stored with a txt file here, so they are just stored

03:53.950 --> 03:54.970
a plain file.

03:54.970 --> 04:02.320
So here oxley dot txt and as you can see here we got all the grabbed all the Oxley here so.

04:03.360 --> 04:09.720
For example, the command displays lines from Oxley that contain the Oxley string here.

04:09.720 --> 04:13.500
So you can also print lines that don't match a given string.

04:13.500 --> 04:21.990
So with the V option here, so grep V, Oxley, oops, Oxley and Oxley dot txt.

04:23.580 --> 04:25.260
This lines here.

04:25.260 --> 04:29.640
As you can see here, we will execute all of the Oxley commands here.

04:29.640 --> 04:37.890
So in general grep is useful for finding text in a collection of files and we can also use command prints,

04:37.890 --> 04:48.300
the lines that contain the string perl in with the names ending here txt for example grep grep, Oxley,

04:48.510 --> 04:51.810
Oxley and txt in a bin here.

04:51.810 --> 04:53.280
So we are not in a bin.

04:53.400 --> 05:00.150
So in this case grep here, let's actually go to bin here cd, cd bin.

05:00.150 --> 05:01.730
We can also write it like that.

05:01.860 --> 05:06.660
Give grep python and txt.

05:07.110 --> 05:08.670
I don't think we're going to have here.

05:08.670 --> 05:13.350
As you can see here, we don't have any python here, so.

05:15.390 --> 05:22.860
And in this case, um, if you have a python here, the grep will fund a matching lines like it did

05:22.860 --> 05:25.700
in the here and print it on the screen.

05:25.740 --> 05:29.940
So we also have the sort command.

05:29.940 --> 05:36.660
So actually let's clear this clear and the sort command reorders the lines of a file into a scanning

05:36.660 --> 05:38.070
order by default.

05:38.070 --> 05:41.220
So you can also change the the scanning or other orders here.

05:41.220 --> 05:50.010
So for example, sort Oxley dot txt and that's not sort here sort.

05:51.430 --> 05:53.390
Sort so you cannot read it.

05:53.410 --> 05:56.890
No such file or directory because we are on a bin directory.

05:56.890 --> 05:59.140
So we're going to go to home here.

05:59.170 --> 06:00.640
Home Kali.

06:00.880 --> 06:10.210
Kali and less clear so sort Oxley dot txt and as you can see here it will sort our file.

06:10.210 --> 06:11.680
So let's actually edit file.

06:11.680 --> 06:14.680
So make it a little more visible like this for example.

06:15.190 --> 06:15.730
Write it.

06:15.730 --> 06:16.690
Apple.

06:16.690 --> 06:17.290
Apple.

06:17.320 --> 06:20.170
BMW Computer.

06:21.170 --> 06:21.890
A zebra.

06:23.540 --> 06:26.840
Windows Linux and here.

06:26.840 --> 06:29.030
So now we're going to write it like that.

06:29.030 --> 06:34.640
And as you can see, Apple, BMW, Computer, Linux, Windows and lastly Zebra.

06:34.640 --> 06:40.190
So it will write it our lines with it, uh, with ascending order.

06:40.190 --> 06:41.420
So this is by default.

06:41.420 --> 06:47.120
So if you want to change it, uh, like this, for example, sort from the descending order.

06:47.300 --> 06:50.210
So you're going to write it like that are here.

06:50.210 --> 06:56.720
So as you can see here first is Zebra, Windows, Linux, Computer, BMW, and lastly A here, which

06:56.720 --> 06:57.860
is Apple here.

06:58.940 --> 07:08.450
So the sort here can order the lines alphabetically by default or numerically with the N option here.

07:08.450 --> 07:16.760
So for example, if we write like that, it's actually let's write it here numbers or actually let's

07:16.760 --> 07:33.290
write something like 2002, 2023, 2009, 2010, 2015, 2024, 2025 and 1098 here.

07:33.290 --> 07:34.760
So write it like that.

07:34.760 --> 07:40.640
And after that we're going to use the, for example, cut here, cut.

07:41.540 --> 07:46.910
So I will demonstrate this with the pipelines that cut the third field in the animals.

07:46.910 --> 07:48.710
So this here, for example.

07:49.490 --> 07:56.660
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

07:56.660 --> 08:05.720
here so let's actually make it like that cut 1F1 and as you can see, we got an same output here.

08:06.050 --> 08:19.130
So now we're going to use that cut F3 animals, animals dot txt after we're going to sort this with

08:19.130 --> 08:21.140
this and and oops.

08:23.040 --> 08:24.270
Oops, not animals here.

08:24.270 --> 08:26.160
It's going to be Oxley here.

08:26.160 --> 08:32.250
So Oxley TXT and as you can see here, we sorted it within the ascending here.

08:32.250 --> 08:42.240
So the first 98 to 9, ten, 15, 23, 24 and 25, but we actually it quite opposite here.

08:42.240 --> 08:48.180
So we started, we ended with 98 and as you can see here, we ended with top numbers.

08:48.180 --> 08:54.840
But first we rated it with the ascending order here and as you can see here, so we can also write it

08:54.990 --> 08:59.340
the scanning order by adding after end, we can also add R here.

08:59.340 --> 09:01.470
So it will write the scanning order.

09:01.470 --> 09:07.200
And as you can see, first we've written the highest number and then it got two from the highest windows

09:07.200 --> 09:07.380
here.

09:07.380 --> 09:09.090
And as you can see here, this is it.

09:09.120 --> 09:17.730
So if you write like that sort and R Oxley dot txt, it will write exactly the same output like this.

09:17.730 --> 09:20.130
So we also have.

09:21.290 --> 09:22.700
The unique command.

09:23.540 --> 09:24.500
Not unique here.

09:24.500 --> 09:25.410
So unique here.

09:25.430 --> 09:26.410
Just unique.

09:26.420 --> 09:28.610
So this unique command.

09:28.640 --> 09:32.330
The texts repeated a jacking lines in a file.

09:32.330 --> 09:35.360
So by default it it removes the repeat.

09:35.370 --> 09:41.690
So here for example, let's add some lines that has same outputs for example.

09:42.900 --> 09:43.920
I'm here.

09:45.270 --> 09:45.550
Oops.

09:46.260 --> 09:46.830
Let's open.

09:46.830 --> 09:50.190
Yeah, let's add some lines.

09:50.190 --> 09:55.800
So let's add Linux twice or three here, windows here.

09:57.160 --> 09:57.410
Oops.

09:57.850 --> 09:58.600
Here.

10:02.980 --> 10:03.580
Here.

10:03.580 --> 10:09.220
So now let's demonstrate here for example, Cat Oxley dot TXT.

10:09.230 --> 10:11.080
And as you can see, we got this here.

10:11.080 --> 10:15.730
So we will use the unique Oxley dot TXT.

10:15.730 --> 10:23.980
And as you can see here, we are not showing the same outputs again and again like this here.

10:23.980 --> 10:31.960
So notice that uniquely use the first three lines to here single in Linux here.

10:32.230 --> 10:38.740
And as you can see here, we got just one Linux, but here we also have two windows, we got one windows

10:38.740 --> 10:43.780
and after that we are just seeing one windows per line.

10:43.780 --> 10:46.390
And after that we are seeing another here.

10:46.390 --> 10:49.330
So we can also use the for example.

10:51.500 --> 10:58.430
Print the gray hour lines with the cut here.

10:58.430 --> 10:59.960
So cut.

11:00.830 --> 11:02.240
Auxiliary text here.

11:02.240 --> 11:04.730
So and we will also that sort.

11:04.970 --> 11:17.240
And here we will use the sort and unique see here sort and are and after that heat here and one and

11:17.240 --> 11:20.420
as you can see we just got five Linux here.
