1
00:00:01,290 --> 00:00:05,950
Let's create some script where we can practice the wildcards.

2
00:00:06,120 --> 00:00:10,110
But firstly we need to do some preparation.

3
00:00:10,110 --> 00:00:19,800
Great director directory Perrott and indeed the directory create few files with PTF extensions.

4
00:00:20,250 --> 00:00:25,920
So textfile one PDA can get also filed too.

5
00:00:26,850 --> 00:00:35,930
And for example something called PTF and you can create also some image file

6
00:00:39,880 --> 00:00:47,920
and also some text file.

7
00:00:48,240 --> 00:00:53,350
You can check that files are created.

8
00:00:53,520 --> 00:01:01,400
Now go back and grade script called back up dot dot sh.

9
00:01:14,290 --> 00:01:17,200
Of course starts with shebang.

10
00:01:17,870 --> 00:01:27,370
Dana Bash and on another line we will write a description of what we are going to build.

11
00:01:27,400 --> 00:01:39,550
Imagine that your boss wants from you to back up all pedia files from Berat location.

12
00:01:39,820 --> 00:01:53,830
So I will go back to copy that part.

13
00:01:54,990 --> 00:01:56,970
So in my case

14
00:02:00,090 --> 00:02:11,880
it is home Richard bash wildcards and your boss wants to copy that files to backup destination

15
00:02:15,070 --> 00:02:26,870
descript should take one out of the man and it is destination bot which needs two ends with Slash Bekka

16
00:02:33,300 --> 00:02:34,350
needs and

17
00:02:38,990 --> 00:02:41,090
with Slash backup

18
00:02:46,150 --> 00:02:47,200
so it can be.

19
00:02:47,200 --> 00:02:52,760
For example home Richard beshe wildcard backup.

20
00:02:52,780 --> 00:02:53,530
In my case

21
00:03:00,790 --> 00:03:07,270
so now we can start the variable assignment.

22
00:03:08,160 --> 00:03:16,480
I will assign into the variable my directory path in your case.

23
00:03:16,480 --> 00:03:21,880
It can be some different directory path.

24
00:03:21,970 --> 00:03:24,100
Now we can do argument check.

25
00:03:24,250 --> 00:03:29,600
So we are sure that descript is run when only one argument is passed.

26
00:03:29,710 --> 00:03:36,170
So if square brackets number of arguments not equal one.

27
00:03:37,030 --> 00:03:44,410
And if that is a valid rule brained uko only one argument

28
00:03:48,730 --> 00:04:01,420
is needed around go or assign zero destination got assigned zero means name of the script and we can

29
00:04:01,510 --> 00:04:06,090
of course exit Scribd here.

30
00:04:06,430 --> 00:04:11,370
If you use a didn't pass an argument or just too much arguments.

31
00:04:11,370 --> 00:04:13,690
So we are exiting with was one

32
00:04:18,250 --> 00:04:19,710
now.

33
00:04:20,260 --> 00:04:23,810
The wildcard spot destination path.

34
00:04:23,920 --> 00:04:24,270
Check

35
00:04:27,820 --> 00:04:35,510
here if we need to check if the destination path and Savitt slash back into destination of variable

36
00:04:35,600 --> 00:04:39,430
assign value of the first argument.

37
00:04:39,530 --> 00:04:40,690
So now right.

38
00:04:40,730 --> 00:04:46,540
If double square brackets are assigned destination

39
00:04:49,210 --> 00:04:50,340
not fo

40
00:04:54,270 --> 00:05:06,380
asterisk which represent any number of characters and slash Back-Up So if destination park doesn't get

41
00:05:06,400 --> 00:05:12,680
back up we will bring in Verdonk destination.

42
00:05:13,000 --> 00:05:18,780
So eco Verdonk destination path

43
00:05:21,190 --> 00:05:36,290
destination path must Antz with Slash like.

44
00:05:37,050 --> 00:05:42,490
And we can program here with some different styles.

45
00:05:42,510 --> 00:05:52,530
For example exit to now we have checked all connections so we can do afterwhile backup actual copy but

46
00:05:52,680 --> 00:06:01,390
we don't we don't have yet great destination folder so great destination for the

47
00:06:05,360 --> 00:06:13,790
for that we need to use and Cadia command to read barometer to be in order to create more than one directories

48
00:06:13,910 --> 00:06:15,640
which do not exist yet.

49
00:06:21,330 --> 00:06:27,580
And V.K. destination and Verby also go in the directory create another directory with current times

50
00:06:27,580 --> 00:06:28,140
then.

51
00:06:28,530 --> 00:06:38,190
So for that I am using date variable and in that date variable I am assigning current date for informa

52
00:06:38,460 --> 00:06:38,820
of

53
00:06:41,850 --> 00:06:42,270
year

54
00:06:45,150 --> 00:06:48,550
month day

55
00:06:53,070 --> 00:06:56,870
and also our

56
00:06:59,520 --> 00:06:59,900
many

57
00:07:03,250 --> 00:07:04,870
and second.

58
00:07:05,290 --> 00:07:15,070
So each time we run this back up script we create new folder where we will backup offerings.

59
00:07:15,100 --> 00:07:21,370
Now we can do copy command copy from brought to destination

60
00:07:26,930 --> 00:07:28,130
so C.P.

61
00:07:35,320 --> 00:07:36,710
a lot of sign brought

62
00:07:40,820 --> 00:07:46,440
and as we want to pick up only be defiance we need to use wild cards again.

63
00:07:46,730 --> 00:07:49,580
So type asterisk dot PTF

64
00:07:52,210 --> 00:07:54,370
and we'll copy to destination.

65
00:07:54,380 --> 00:07:57,140
Slash date.

66
00:08:03,830 --> 00:08:08,270
Now we can also for a recap from previous sections.

67
00:08:08,310 --> 00:08:10,610
That's the exit status of Kopitar month.

68
00:08:10,670 --> 00:08:17,400
So if exists that was of last month equals to zero.

69
00:08:19,150 --> 00:08:23,960
We can print something gleich back up OK.

70
00:08:25,280 --> 00:08:36,490
So if it is that those of last month is equal to zero then equal back up ok.

71
00:08:36,550 --> 00:08:49,790
Otherwise we can bring back up failed.

72
00:08:49,810 --> 00:08:52,240
Now you can save descript

73
00:08:57,500 --> 00:09:02,760
and Vinick to grant permission using chinch month.

74
00:09:03,800 --> 00:09:05,900
And now we can go around descript

75
00:09:11,950 --> 00:09:18,490
I will check all part of my working directory and I will copy that as a scrip argument.

76
00:09:22,580 --> 00:09:24,120
Or maybe not it.

77
00:09:24,140 --> 00:09:29,890
Firstly I will just call a script without any arguments to see it is working.

78
00:09:30,350 --> 00:09:36,750
And then as I got message only one argument is needed because as age destination.

79
00:09:37,010 --> 00:09:41,690
Great This works perfectly in this eco command.

80
00:09:41,690 --> 00:09:45,810
We will do our signs 0 which represents descript name.

81
00:09:45,920 --> 00:09:52,630
And here we can truly see around back up broad as age great.

82
00:09:52,760 --> 00:10:00,220
Now I can pass my working directory but as an honorable man and great Scribners as it did because of

83
00:10:00,220 --> 00:10:01,220
wrong destination.

84
00:10:01,220 --> 00:10:05,590
But I can change the destination part and direct and

85
00:10:09,790 --> 00:10:13,010
is say wrong destination.

86
00:10:14,250 --> 00:10:18,760
Now I can fix it to end with back up and it says Bekka.

87
00:10:18,860 --> 00:10:20,620
Okay great.

88
00:10:20,970 --> 00:10:23,730
So let's check the destination folder.

89
00:10:28,320 --> 00:10:36,480
And I can see that in destination folder it is created timestamp folder with free media files.

90
00:10:36,480 --> 00:10:37,600
Pretty amazing.

91
00:10:42,680 --> 00:10:46,450
So now let's just around descript.

92
00:10:46,460 --> 00:10:47,060
Again

93
00:10:50,980 --> 00:10:52,170
OK.

94
00:10:53,080 --> 00:10:55,210
And check destination Forder.

95
00:11:07,160 --> 00:11:11,540
And we can see that we have time stamps folder here now.

96
00:11:11,810 --> 00:11:13,940
Great.

97
00:11:14,070 --> 00:11:21,220
I recommend you now to go through our script one time or to be sure that you understand everything.

98
00:11:21,900 --> 00:11:23,480
So see you in next lecture.
