1
00:00:00,710 --> 00:00:01,880
Hello, my name is Stephan.

2
00:00:01,880 --> 00:00:06,470
And in this lecture of our course, you will learn about the heat command in Linux.

3
00:00:06,470 --> 00:00:07,880
So let's get started.

4
00:00:20,970 --> 00:00:25,370
So the heat command prints the first lines of a file.

5
00:00:25,380 --> 00:00:29,700
So to print the first four lines of our auxiliary.

6
00:00:30,540 --> 00:00:37,650
With here auxiliary text file with heat, we can use the option n so heat n for.

7
00:00:39,170 --> 00:00:41,870
And four and Oxley here.

8
00:00:42,080 --> 00:00:46,790
And as you can see here, we printed first four lines of our Oxley text file.

9
00:00:46,790 --> 00:00:54,940
So if you request more file more lines than the file contains the heat prints, the full file like keta.

10
00:00:54,950 --> 00: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

11
00:01:02,210 --> 00:01:03,950
it like that and.

12
00:01:04,740 --> 00:01:09,000
11, then it will just print the six lines here.

13
00:01:09,000 --> 00:01:17,330
So it will print whole file so he can also read from the STD in four mile pipeline fun.

14
00:01:17,340 --> 00: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.

15
00:01:24,840 --> 00:01:33,450
So like a long directory listing, for example, let's list the first five file names in the bin directory

16
00:01:33,450 --> 00:01:33,660
here.

17
00:01:33,660 --> 00:01:38,070
So or let's actually 15 file names in the bin directory.

18
00:01:38,070 --> 00:01:42,120
So bin hit and it's going to be.

19
00:01:42,910 --> 00:01:43,600
15.

20
00:01:43,600 --> 00:01:48,250
And as you can see, we printed the first 15 lines in the bind directory.

21
00:01:48,280 --> 00:01:51,000
We also have the cut command.

22
00:01:51,010 --> 00:01:56,020
So the cut command prints one or more columns for a file, for example.

23
00:01:56,410 --> 00:01:57,220
Let's actually here.

24
00:01:57,220 --> 00:01:57,820
So.

25
00:01:58,650 --> 00:02:06,270
Let's print all titles from the auxiliary file which appear in the here, for example.

26
00:02:06,870 --> 00:02:11,010
Cut F2 and Oxley here.

27
00:02:11,010 --> 00:02:13,200
And as you can see, we got this here.

28
00:02:13,200 --> 00:02:17,630
So cut provides two ways to define what columns.

29
00:02:17,640 --> 00:02:21,720
So the first is to cut by field F here.

30
00:02:21,720 --> 00:02:28,500
So this f when the input consists of string fields, each separated by a single tab character.

31
00:02:28,500 --> 00:02:34,170
So conveniently, this is exactly the format of a file of Oxley here.

32
00:02:34,170 --> 00:02:39,810
So the preceding cut command prints the second field of each file.

33
00:02:39,810 --> 00:02:43,710
So if we write it like that one here or.

34
00:02:45,260 --> 00:02:48,440
F3 and as you can see here.

35
00:02:48,440 --> 00:02:50,690
So we can also do that like that here.

36
00:02:52,410 --> 00:02:54,460
Here and let's run it again.

37
00:02:54,480 --> 00:02:59,610
And as you can see here, we got a different output.

38
00:02:59,850 --> 00:03:08,910
So to shorten the output, we can also use the pipe it to heat the print only the first three lines

39
00:03:08,910 --> 00:03:10,860
and so on.

40
00:03:10,860 --> 00:03:17,760
So now let's actually use the grep command in our Linux command training here.

41
00:03:17,760 --> 00:03:24,270
So grep is an extremely powerful command, but for now I will hide most of its capabilities and say

42
00:03:24,270 --> 00:03:27,660
it prints the lines that match a given string.

43
00:03:27,660 --> 00:03:32,010
So for example, let's like it here grep.

44
00:03:33,550 --> 00:03:36,550
Oxley and Oxley here.

45
00:03:36,550 --> 00:03:41,020
So Oxley is a text file, so let's actually change it from the UI here.

46
00:03:41,050 --> 00: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

47
00:03:47,590 --> 00:03:48,340
file here.

48
00:03:48,340 --> 00:03:53,940
But for Linux it's actually text files is not stored with a txt file here, so they are just stored

49
00:03:53,950 --> 00:03:54,970
a plain file.

50
00:03:54,970 --> 00:04:02,320
So here oxley dot txt and as you can see here we got all the grabbed all the Oxley here so.

51
00:04:03,360 --> 00:04:09,720
For example, the command displays lines from Oxley that contain the Oxley string here.

52
00:04:09,720 --> 00:04:13,500
So you can also print lines that don't match a given string.

53
00:04:13,500 --> 00:04:21,990
So with the V option here, so grep V, Oxley, oops, Oxley and Oxley dot txt.

54
00:04:23,580 --> 00:04:25,260
This lines here.

55
00:04:25,260 --> 00:04:29,640
As you can see here, we will execute all of the Oxley commands here.

56
00:04:29,640 --> 00:04:37,890
So in general grep is useful for finding text in a collection of files and we can also use command prints,

57
00:04:37,890 --> 00:04:48,300
the lines that contain the string perl in with the names ending here txt for example grep grep, Oxley,

58
00:04:48,510 --> 00:04:51,810
Oxley and txt in a bin here.

59
00:04:51,810 --> 00:04:53,280
So we are not in a bin.

60
00:04:53,400 --> 00:05:00,150
So in this case grep here, let's actually go to bin here cd, cd bin.

61
00:05:00,150 --> 00:05:01,730
We can also write it like that.

62
00:05:01,860 --> 00:05:06,660
Give grep python and txt.

63
00:05:07,110 --> 00:05:08,670
I don't think we're going to have here.

64
00:05:08,670 --> 00:05:13,350
As you can see here, we don't have any python here, so.

65
00:05:15,390 --> 00:05:22,860
And in this case, um, if you have a python here, the grep will fund a matching lines like it did

66
00:05:22,860 --> 00:05:25,700
in the here and print it on the screen.

67
00:05:25,740 --> 00:05:29,940
So we also have the sort command.

68
00:05:29,940 --> 00:05:36,660
So actually let's clear this clear and the sort command reorders the lines of a file into a scanning

69
00:05:36,660 --> 00:05:38,070
order by default.

70
00:05:38,070 --> 00:05:41,220
So you can also change the the scanning or other orders here.

71
00:05:41,220 --> 00:05:50,010
So for example, sort Oxley dot txt and that's not sort here sort.

72
00:05:51,430 --> 00:05:53,390
Sort so you cannot read it.

73
00:05:53,410 --> 00:05:56,890
No such file or directory because we are on a bin directory.

74
00:05:56,890 --> 00:05:59,140
So we're going to go to home here.

75
00:05:59,170 --> 00:06:00,640
Home Kali.

76
00:06:00,880 --> 00:06:10,210
Kali and less clear so sort Oxley dot txt and as you can see here it will sort our file.

77
00:06:10,210 --> 00:06:11,680
So let's actually edit file.

78
00:06:11,680 --> 00:06:14,680
So make it a little more visible like this for example.

79
00:06:15,190 --> 00:06:15,730
Write it.

80
00:06:15,730 --> 00:06:16,690
Apple.

81
00:06:16,690 --> 00:06:17,290
Apple.

82
00:06:17,320 --> 00:06:20,170
BMW Computer.

83
00:06:21,170 --> 00:06:21,890
A zebra.

84
00:06:23,540 --> 00:06:26,840
Windows Linux and here.

85
00:06:26,840 --> 00:06:29,030
So now we're going to write it like that.

86
00:06:29,030 --> 00:06:34,640
And as you can see, Apple, BMW, Computer, Linux, Windows and lastly Zebra.

87
00:06:34,640 --> 00:06:40,190
So it will write it our lines with it, uh, with ascending order.

88
00:06:40,190 --> 00:06:41,420
So this is by default.

89
00:06:41,420 --> 00:06:47,120
So if you want to change it, uh, like this, for example, sort from the descending order.

90
00:06:47,300 --> 00:06:50,210
So you're going to write it like that are here.

91
00:06:50,210 --> 00:06:56,720
So as you can see here first is Zebra, Windows, Linux, Computer, BMW, and lastly A here, which

92
00:06:56,720 --> 00:06:57,860
is Apple here.

93
00:06:58,940 --> 00:07:08,450
So the sort here can order the lines alphabetically by default or numerically with the N option here.

94
00:07:08,450 --> 00:07:16,760
So for example, if we write like that, it's actually let's write it here numbers or actually let's

95
00:07:16,760 --> 00:07:33,290
write something like 2002, 2023, 2009, 2010, 2015, 2024, 2025 and 1098 here.

96
00:07:33,290 --> 00:07:34,760
So write it like that.

97
00:07:34,760 --> 00:07:40,640
And after that we're going to use the, for example, cut here, cut.

98
00:07:41,540 --> 00:07:46,910
So I will demonstrate this with the pipelines that cut the third field in the animals.

99
00:07:46,910 --> 00:07:48,710
So this here, for example.

100
00:07:49,490 --> 00: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

101
00:07:56,660 --> 00: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.

102
00:08:06,050 --> 00: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

103
00:08:19,130 --> 00:08:21,140
this and and oops.

104
00:08:23,040 --> 00:08:24,270
Oops, not animals here.

105
00:08:24,270 --> 00:08:26,160
It's going to be Oxley here.

106
00:08:26,160 --> 00:08:32,250
So Oxley TXT and as you can see here, we sorted it within the ascending here.

107
00:08:32,250 --> 00:08:42,240
So the first 98 to 9, ten, 15, 23, 24 and 25, but we actually it quite opposite here.

108
00:08:42,240 --> 00:08:48,180
So we started, we ended with 98 and as you can see here, we ended with top numbers.

109
00:08:48,180 --> 00: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

110
00:08:54,990 --> 00:08:59,340
the scanning order by adding after end, we can also add R here.

111
00:08:59,340 --> 00:09:01,470
So it will write the scanning order.

112
00:09:01,470 --> 00:09:07,200
And as you can see, first we've written the highest number and then it got two from the highest windows

113
00:09:07,200 --> 00:09:07,380
here.

114
00:09:07,380 --> 00:09:09,090
And as you can see here, this is it.

115
00:09:09,120 --> 00:09:17,730
So if you write like that sort and R Oxley dot txt, it will write exactly the same output like this.

116
00:09:17,730 --> 00:09:20,130
So we also have.

117
00:09:21,290 --> 00:09:22,700
The unique command.

118
00:09:23,540 --> 00:09:24,500
Not unique here.

119
00:09:24,500 --> 00:09:25,410
So unique here.

120
00:09:25,430 --> 00:09:26,410
Just unique.

121
00:09:26,420 --> 00:09:28,610
So this unique command.

122
00:09:28,640 --> 00:09:32,330
The texts repeated a jacking lines in a file.

123
00:09:32,330 --> 00:09:35,360
So by default it it removes the repeat.

124
00:09:35,370 --> 00:09:41,690
So here for example, let's add some lines that has same outputs for example.

125
00:09:42,900 --> 00:09:43,920
I'm here.

126
00:09:45,270 --> 00:09:45,550
Oops.

127
00:09:46,260 --> 00:09:46,830
Let's open.

128
00:09:46,830 --> 00:09:50,190
Yeah, let's add some lines.

129
00:09:50,190 --> 00:09:55,800
So let's add Linux twice or three here, windows here.

130
00:09:57,160 --> 00:09:57,410
Oops.

131
00:09:57,850 --> 00:09:58,600
Here.

132
00:10:02,980 --> 00:10:03,580
Here.

133
00:10:03,580 --> 00:10:09,220
So now let's demonstrate here for example, Cat Oxley dot TXT.

134
00:10:09,230 --> 00:10:11,080
And as you can see, we got this here.

135
00:10:11,080 --> 00:10:15,730
So we will use the unique Oxley dot TXT.

136
00:10:15,730 --> 00:10:23,980
And as you can see here, we are not showing the same outputs again and again like this here.

137
00:10:23,980 --> 00:10:31,960
So notice that uniquely use the first three lines to here single in Linux here.

138
00:10:32,230 --> 00: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

139
00:10:38,740 --> 00:10:43,780
and after that we are just seeing one windows per line.

140
00:10:43,780 --> 00:10:46,390
And after that we are seeing another here.

141
00:10:46,390 --> 00:10:49,330
So we can also use the for example.

142
00:10:51,500 --> 00:10:58,430
Print the gray hour lines with the cut here.

143
00:10:58,430 --> 00:10:59,960
So cut.

144
00:11:00,830 --> 00:11:02,240
Auxiliary text here.

145
00:11:02,240 --> 00:11:04,730
So and we will also that sort.

146
00:11:04,970 --> 00: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

147
00:11:17,240 --> 00:11:20,420
as you can see we just got five Linux here.
