1
00:00:01,380 --> 00:00:08,220
So in this lecture we would like to display file content with space and top issues in that background

2
00:00:08,220 --> 00:00:09,180
color.

3
00:00:09,180 --> 00:00:14,070
So in order to display file content we need to read line by line.

4
00:00:14,820 --> 00:00:24,510
So just after fixing our bright command display graphically space errors so we exactly know what we

5
00:00:24,510 --> 00:00:27,030
are doing.

6
00:00:38,790 --> 00:00:47,400
Firstly we need to be sure that user specified files which exist as we want to read line by line from

7
00:00:47,400 --> 00:00:48,840
that file.

8
00:00:48,930 --> 00:00:57,270
So use Desch f overarm for checking if variable file represents regular file.

9
00:00:57,810 --> 00:01:08,230
Now if we are sure that we have a regular file that read line by line from that file but in order to

10
00:01:08,230 --> 00:01:15,610
read line with space and top issue use instead of violating line.

11
00:01:15,850 --> 00:01:27,810
So instead of that you need to use while internal field separator segfaults to read them at a line.

12
00:01:27,820 --> 00:01:33,870
This ensures us that inherit lines will be all spaces and taps without any change.

13
00:01:33,910 --> 00:01:41,020
Otherwise we will only violate the line we vote on secretly spaces and thus at the beginning or at the

14
00:01:41,020 --> 00:01:42,510
end of lines.

15
00:01:43,210 --> 00:01:52,130
And of course we are getting clients from variable file which represents files specified by user.

16
00:01:52,170 --> 00:01:58,490
So now we need to think what we will do if line will have some space or top issue.

17
00:01:58,530 --> 00:02:02,300
We need to show that space and that part inherit background.

18
00:02:02,520 --> 00:02:07,890
Otherwise if line has no space or that we should just print this line.

19
00:02:07,890 --> 00:02:14,640
So now we can do that by printing whole line if there is no space visual You can write a comment about

20
00:02:14,640 --> 00:02:15,890
that also.

21
00:02:20,700 --> 00:02:25,340
So if there is no space issue on line just print the line

22
00:02:32,680 --> 00:02:42,340
for checking if there is space or top issue at the beginning or the end of the line we will use SET

23
00:02:42,520 --> 00:02:43,410
command.

24
00:02:43,470 --> 00:02:43,890
Q

25
00:02:46,690 --> 00:02:54,880
So if we find space or top which is represented by character class blahing.

26
00:02:55,000 --> 00:02:57,450
So if we find space or top issue

27
00:03:00,720 --> 00:03:03,990
at the end of a line

28
00:03:07,020 --> 00:03:20,100
and or line is presented by the sign Viva exist with exit status for example 9 and if there is space

29
00:03:20,220 --> 00:03:23,820
or issue a deep beginning of that line.

30
00:03:37,280 --> 00:03:38,390
We will exit.

31
00:03:38,390 --> 00:03:42,330
For example read exit's that was 7.

32
00:03:42,890 --> 00:03:51,970
And as we don't want to print now anything to the screen we need to direct output from set command to

33
00:03:52,010 --> 00:03:53,790
Dev-Null.

34
00:03:55,130 --> 00:04:02,180
So just to recap if we find at least one space or two up this is the reason why we are using in a regular

35
00:04:02,180 --> 00:04:04,110
expression bus symbol.

36
00:04:04,130 --> 00:04:10,430
So if we find spaces or taps a deep end of lines we are exiting with exits.

37
00:04:10,430 --> 00:04:11,650
That was 9.

38
00:04:11,810 --> 00:04:20,500
And if you find spaces or tabs at the beginning of a line we will exit exits that was seven.

39
00:04:20,630 --> 00:04:24,520
Now we can ask if exit status is zero.

40
00:04:24,590 --> 00:04:33,620
That means if no error was spotted in this line so even though error was spotted in diesel line we can

41
00:04:33,620 --> 00:04:36,490
just print the line to the screen

42
00:04:41,760 --> 00:04:54,860
so I echo the lower side line and then we can use keyboard continuing to continue Kieve or does it finish

43
00:04:54,950 --> 00:04:57,910
actually low and continue with another one.

44
00:04:58,100 --> 00:05:03,870
So in our case it would jump to the next line in a while loop.

45
00:05:04,130 --> 00:05:10,620
We can of course use for example statement if we don't want to use continue command.

46
00:05:10,820 --> 00:05:18,120
And in that statement we will specify part of code for case exit status is not zero.

47
00:05:18,140 --> 00:05:24,300
So that means for days when in the line was spotted some spaces are a top issue.

48
00:05:24,740 --> 00:05:29,290
But I will go in this case of it continue command.

49
00:05:30,080 --> 00:05:38,240
So we basically wrote code for reading each line and for each line we are checking if there is space

50
00:05:38,300 --> 00:05:39,500
or a tab issue.

51
00:05:39,620 --> 00:05:46,790
At the beginning or at the end of line if there is no issue for a specific line we are printing this

52
00:05:46,790 --> 00:05:47,830
line.

53
00:05:47,870 --> 00:05:50,010
So now let's test it.

54
00:05:55,070 --> 00:05:59,170
From our script and specify some file location

55
00:06:03,960 --> 00:06:07,680
and I can see it printed all the lines without space issue.

56
00:06:07,680 --> 00:06:08,530
Good.

57
00:06:08,970 --> 00:06:12,660
Now open our test file and make space.

58
00:06:12,660 --> 00:06:15,340
Our top issue on multiple lines.

59
00:06:18,890 --> 00:06:27,170
For example I have some space issues in the first line and also in the search line.

60
00:06:27,540 --> 00:06:36,310
When running our script again I cannot see first and line as those lines contain space or type issue.

61
00:06:36,320 --> 00:06:37,910
This is working perfectly.
