1
00:00:02,310 --> 00:00:05,130
I would start with opening our script

2
00:00:09,710 --> 00:00:17,190
and we have already written what should happen with an extension specified by user is not found.

3
00:00:17,310 --> 00:00:26,040
So now in this part of code we know that user has specified some extension and we know that debt extension

4
00:00:26,250 --> 00:00:29,180
exists in a location directory.

5
00:00:30,030 --> 00:00:34,520
So we can now count the size of files of its specific extension.

6
00:00:34,800 --> 00:00:37,130
And if you practice it in the last lecture.

7
00:00:37,980 --> 00:00:40,570
So now we can write some command.

8
00:00:40,590 --> 00:00:48,830
What we are going to do come the size of files with specific extension

9
00:00:54,500 --> 00:01:00,680
so now pass output of ls l command for location variable

10
00:01:06,330 --> 00:01:10,560
so pass it into oxcart awk program

11
00:01:13,530 --> 00:01:22,410
and we will select only files that means that we will use only lines which starting with Desch and this

12
00:01:22,410 --> 00:01:25,260
output will pass into up come on

13
00:01:28,930 --> 00:01:34,450
and in that command we select the lines which ends with specific extension

14
00:01:38,800 --> 00:01:44,370
and this output will help into another awk program.

15
00:01:52,350 --> 00:02:04,230
And in the main section of that old program will count some.

16
00:02:04,440 --> 00:02:13,900
So we can now create variable sum which will be incremented for each record by fifth field

17
00:02:16,890 --> 00:02:23,250
but thats not all because we want to also know what is the largest and smallest file.

18
00:02:23,310 --> 00:02:29,780
So we need to define variables min and max out to do that.

19
00:02:29,880 --> 00:02:37,380
It would be good for first time for first record set into variables min and max value of fifth column

20
00:02:37,620 --> 00:02:46,400
of the record and then for another record for another line we would compare a fifth on that value of

21
00:02:46,410 --> 00:02:48,210
variable min and max.

22
00:02:48,210 --> 00:02:49,760
So lets do that.

23
00:02:50,340 --> 00:03:03,960
So for first record when a number of record is equal to 1 we can set a minimum to be value of Fifield

24
00:03:05,490 --> 00:03:16,920
maximum Will we also value of Fifield and we can set value of nine field which is file name into variable

25
00:03:16,990 --> 00:03:17,670
middle name

26
00:03:21,510 --> 00:03:22,690
and the same.

27
00:03:22,710 --> 00:03:29,650
We will do also for Max name.

28
00:03:29,820 --> 00:03:33,780
So now the initial setting is done and we can compare

29
00:03:37,010 --> 00:03:47,340
if value of Fifield is greater than value of variable mocs we will assign new value to variable Max

30
00:03:47,620 --> 00:03:49,080
as value is bigger

31
00:04:00,900 --> 00:04:06,020
and also V-Star new value into variable Max name

32
00:04:13,190 --> 00:04:16,150
and now we can do the same

33
00:04:19,230 --> 00:04:30,380
for case when in summary court will be value of field less then value of mean variable.

34
00:04:30,450 --> 00:04:43,020
So in that case mean a variable will have to that variable assign value of Fifield and to variable name

35
00:04:43,110 --> 00:04:50,080
Leavell assign value of nine field.

36
00:04:50,670 --> 00:04:56,790
And we have basically finished Main awk section which is done for all our records.

37
00:04:56,790 --> 00:05:05,470
In our case for each line of our command where are displayed only files of specific extension but we

38
00:05:05,470 --> 00:05:10,910
should also bring to user what is the actual disk size of those files.

39
00:05:10,930 --> 00:05:17,290
So in the end section when everything is counted we can print some

40
00:05:21,370 --> 00:05:28,060
sold us government print and print the actual song

41
00:05:38,520 --> 00:05:42,020
and we can display it in megabytes.

42
00:05:42,600 --> 00:05:47,220
So due to division by one thousand twenty four two times

43
00:05:52,050 --> 00:06:00,830
and we can also print how many files with specific extension is present using number of records of variable

44
00:06:02,290 --> 00:06:17,080
so right files and news variable and our present number of records and that's all we go line by line

45
00:06:17,260 --> 00:06:24,370
and checking if Fifield of each line is greater than maximum or if it is less than the minimum.

46
00:06:24,370 --> 00:06:30,380
And if yes we are setting a new values to variables min and max at the end.

47
00:06:30,610 --> 00:06:38,520
We are printing what is the actual sum and how many files of it specific extension are present.

48
00:06:39,280 --> 00:06:47,320
We can save the script and run it specify some location and some existing extension

49
00:06:55,030 --> 00:06:56,340
and it is working.

50
00:06:56,370 --> 00:06:57,460
The actual size.

51
00:06:57,490 --> 00:07:04,590
And how many files of its specific extension is present in that specified directory great.

52
00:07:04,810 --> 00:07:07,980
Now we use some not existing extension.

53
00:07:08,020 --> 00:07:08,790
Good.

54
00:07:08,920 --> 00:07:12,350
We see that no file with the set extension was found.

55
00:07:12,400 --> 00:07:13,640
It is working well.

56
00:07:13,840 --> 00:07:19,540
But if we don't specify any extension we don't see any sum for a specified directory.

57
00:07:19,670 --> 00:07:27,220
And also we don't have the logic for printing statistics so we need to fix it all in the next election.
