1
00:00:01,140 --> 00:00:05,320
So let's make some script where we can use vinyl.

2
00:00:05,790 --> 00:00:21,870
Great file called print as age on the first line start shoving been Bash and what we are going to build

3
00:00:21,870 --> 00:00:22,490
here.

4
00:00:22,860 --> 00:00:27,220
We will create a script for a reading.

5
00:00:28,590 --> 00:00:36,660
Or maybe it would be better to say for printing files which will display also

6
00:00:41,080 --> 00:00:44,230
line numbers.

7
00:00:44,230 --> 00:00:53,300
So basically we are going to build something similar to copy command but we will also line numbers script

8
00:00:53,360 --> 00:00:58,700
to take only one argument and that will be filed by.

9
00:00:59,800 --> 00:01:10,940
So we can start with argument check if number of arguments is different from one

10
00:01:13,520 --> 00:01:17,350
then we can fit into zero.

11
00:01:18,470 --> 00:01:19,910
Exactly.

12
00:01:20,000 --> 00:01:23,980
One argument is needed

13
00:01:26,930 --> 00:01:33,310
around the live sign is 0 which is in our script which is our script name.

14
00:01:33,320 --> 00:01:36,270
And this will be followed by file path.

15
00:01:36,740 --> 00:01:44,200
And of course exit rate start those run here.

16
00:01:44,420 --> 00:01:51,290
Now we can assign value of that first argument into a variable called Fireline

17
00:01:56,670 --> 00:02:05,190
and as we need to count blind numbers we need some counters so craved variable count and assigned number

18
00:02:05,280 --> 00:02:07,660
1 to it.

19
00:02:07,840 --> 00:02:11,930
Now if actually reading we can write.

20
00:02:12,600 --> 00:02:21,360
While read line we can use an other different variable name as for example Vohra but the convention

21
00:02:21,360 --> 00:02:22,650
here is to line

22
00:02:25,560 --> 00:02:31,260
and for each line we will perform some commands between keyboards do and dumb.

23
00:02:31,540 --> 00:02:36,540
So we will print a line number represented by variable count

24
00:02:39,090 --> 00:02:41,910
and then we will print on the same line.

25
00:02:41,910 --> 00:02:44,460
The actual line from file

26
00:02:47,520 --> 00:02:50,150
and of course we need to increase Kantar here.

27
00:02:50,160 --> 00:02:55,600
So we see correct lines and line numbers.

28
00:02:55,650 --> 00:02:58,520
Now we need to provide some data into viable.

29
00:02:58,530 --> 00:03:03,720
So we will direct our file pop into vinyl loops standart input

30
00:03:09,420 --> 00:03:15,640
scrape is down but it would be nice to do some checking if provided argument is an existing file

31
00:03:18,200 --> 00:03:23,550
so we can firstly create some command about it.

32
00:03:25,640 --> 00:03:26,080
Check

33
00:03:29,150 --> 00:03:32,210
if provided command

34
00:03:35,520 --> 00:03:40,160
is efile.

35
00:03:40,190 --> 00:03:55,050
So if file exists so I am using operand and maybe better would be to ask if that file doesn't exist.

36
00:03:55,190 --> 00:04:03,810
So I I will negate this by prepending exclamation mark.

37
00:04:04,320 --> 00:04:07,710
And then we can print to screen file.

38
00:04:07,710 --> 00:04:08,910
You have specified

39
00:04:16,090 --> 00:04:17,720
does not exist.

40
00:04:20,170 --> 00:04:23,560
And we can of course exit here with some status.

41
00:04:23,560 --> 00:04:29,410
For example it starts to now we can save descript

42
00:04:46,360 --> 00:04:48,070
ground with permissions

43
00:04:52,790 --> 00:05:00,020
and we can also create some test file which then will be read by our ascript

44
00:05:06,380 --> 00:05:16,740
So some data we'd like one line to something here.

45
00:05:20,140 --> 00:05:28,390
Something else like the five save the file and we can now print that file by using our script

46
00:05:35,170 --> 00:05:36,330
Oh that's nice.

47
00:05:36,340 --> 00:05:40,680
We see all lines but we also see a line numbering.

48
00:05:40,810 --> 00:05:42,210
Great.

49
00:05:42,220 --> 00:05:48,510
Now let's open some bigger file for example Basford file

50
00:05:52,030 --> 00:05:52,760
grade.

51
00:05:52,780 --> 00:05:53,900
It is working.

52
00:05:53,920 --> 00:05:57,010
I see in my case 41 lines.

53
00:05:57,070 --> 00:05:58,430
Pretty amazing.

54
00:06:01,100 --> 00:06:09,280
Do you remember on Tillery lecture where I told you that we have another option how to read files.

55
00:06:09,380 --> 00:06:18,770
So let's try but firstly I will copy our script and rename it to print to good as a

56
00:06:22,690 --> 00:06:23,640
we can open it

57
00:06:32,490 --> 00:06:37,940
and just before the start of a viable up we will provide data.

58
00:06:37,960 --> 00:06:41,200
Do it using pipe Soave right.

59
00:06:41,220 --> 00:06:43,500
Got file name

60
00:06:48,570 --> 00:06:49,130
type

61
00:06:52,110 --> 00:06:57,480
and of course delete file name variable next to Dom keyboard

62
00:07:01,570 --> 00:07:02,420
we can save it

63
00:07:11,210 --> 00:07:15,920
and RAM to see if it is working.

64
00:07:17,170 --> 00:07:20,090
And I am using passport file again.

65
00:07:22,450 --> 00:07:24,720
And it is working great.

66
00:07:31,990 --> 00:07:38,610
But now let's do some interesting experiment with internal field separator.

67
00:07:39,250 --> 00:07:42,430
I will firstly clear the screen

68
00:07:50,130 --> 00:07:59,630
then open print s age and they remove double quotation marks next to file name variable

69
00:08:04,230 --> 00:08:05,160
save descript

70
00:08:09,820 --> 00:08:11,140
Now Kobe.

71
00:08:11,180 --> 00:08:25,420
Our test file and rename it to hello body dot text with the space between the hello and body.

72
00:08:25,450 --> 00:08:29,240
Now if you want to print Hello body file

73
00:08:37,510 --> 00:08:44,390
we are receiving error message Eevee printed with installed or s h

74
00:08:49,200 --> 00:08:57,370
we can see content of that file so only one difference here is removed quotation marks for file name

75
00:08:57,370 --> 00:08:58,200
variable.

76
00:08:58,330 --> 00:09:00,860
But of-I it is behaving this way.

77
00:09:02,380 --> 00:09:06,050
Firstly check the value of internal fields separator

78
00:09:10,520 --> 00:09:20,690
Visi that fields are separated by space DUP and New Line as if you didn't use for a file and pop quotation

79
00:09:20,690 --> 00:09:21,930
marks.

80
00:09:21,950 --> 00:09:29,770
It separated our file a whole body because there is a space in the name of dead file.

81
00:09:30,160 --> 00:09:38,680
But what would happen if we change into now field separator to only new lines then our file our whole

82
00:09:38,680 --> 00:09:43,690
body wouldn't be separated and rendered under script.

83
00:09:43,930 --> 00:09:45,950
We should see file content.

84
00:09:46,000 --> 00:09:50,600
So let's experiment open into dot S H

85
00:09:53,250 --> 00:10:00,220
and set into another field separator to be separated only on a new line

86
00:10:08,890 --> 00:10:11,450
you noticed that at the beginning.

87
00:10:11,500 --> 00:10:13,250
We have dollar sign.

88
00:10:13,450 --> 00:10:17,810
If we didn't use it it would in our case separate.

89
00:10:17,860 --> 00:10:25,990
Not on a new line but on a character end and also on backslash character.

90
00:10:26,050 --> 00:10:34,380
So basically it means when we are using Dorsai in backslash is not a normal backslash but it is now.

91
00:10:34,690 --> 00:10:42,100
Escape character which together with any character means new line.

92
00:10:42,270 --> 00:10:47,820
So now save the script and add on discrete different fields separated

93
00:10:58,980 --> 00:11:00,620
and it is working.

94
00:11:00,990 --> 00:11:04,900
We have changed internat field separator to a new line.

95
00:11:05,040 --> 00:11:13,770
So now we can see content of a whole body file because in a whole body file name is no new line character

96
00:11:14,070 --> 00:11:17,630
which would separate the file name.

97
00:11:17,910 --> 00:11:26,170
So advice here is to always use double quotation marks when reading files or even checking if they exist.
