Let's create some script where we can practice the wildcards.
But firstly we need to do some preparation.
Great director directory Perrott and indeed the directory create few files with PTF extensions.
So textfile one PDA can get also filed too.
And for example something called PTF and you can create also some image file
and also some text file.
You can check that files are created.
Now go back and grade script called back up dot dot sh.
Of course starts with shebang.
Dana Bash and on another line we will write a description of what we are going to build.
Imagine that your boss wants from you to back up all pedia files from Berat location.
So I will go back to copy that part.
So in my case
it is home Richard bash wildcards and your boss wants to copy that files to backup destination
descript should take one out of the man and it is destination bot which needs two ends with Slash Bekka
needs and
with Slash backup
so it can be.
For example home Richard beshe wildcard backup.
In my case
so now we can start the variable assignment.
I will assign into the variable my directory path in your case.
It can be some different directory path.
Now we can do argument check.
So we are sure that descript is run when only one argument is passed.
So if square brackets number of arguments not equal one.
And if that is a valid rule brained uko only one argument
is needed around go or assign zero destination got assigned zero means name of the script and we can
of course exit Scribd here.
If you use a didn't pass an argument or just too much arguments.
So we are exiting with was one
now.
The wildcard spot destination path.
Check
here if we need to check if the destination path and Savitt slash back into destination of variable
assign value of the first argument.
So now right.
If double square brackets are assigned destination
not fo
asterisk which represent any number of characters and slash Back-Up So if destination park doesn't get
back up we will bring in Verdonk destination.
So eco Verdonk destination path
destination path must Antz with Slash like.
And we can program here with some different styles.
For example exit to now we have checked all connections so we can do afterwhile backup actual copy but
we don't we don't have yet great destination folder so great destination for the
for that we need to use and Cadia command to read barometer to be in order to create more than one directories
which do not exist yet.
And V.K. destination and Verby also go in the directory create another directory with current times
then.
So for that I am using date variable and in that date variable I am assigning current date for informa
of
year
month day
and also our
many
and second.
So each time we run this back up script we create new folder where we will backup offerings.
Now we can do copy command copy from brought to destination
so C.P.
a lot of sign brought
and as we want to pick up only be defiance we need to use wild cards again.
So type asterisk dot PTF
and we'll copy to destination.
Slash date.
Now we can also for a recap from previous sections.
That's the exit status of Kopitar month.
So if exists that was of last month equals to zero.
We can print something gleich back up OK.
So if it is that those of last month is equal to zero then equal back up ok.
Otherwise we can bring back up failed.
Now you can save descript
and Vinick to grant permission using chinch month.
And now we can go around descript
I will check all part of my working directory and I will copy that as a scrip argument.
Or maybe not it.
Firstly I will just call a script without any arguments to see it is working.
And then as I got message only one argument is needed because as age destination.
Great This works perfectly in this eco command.
We will do our signs 0 which represents descript name.
And here we can truly see around back up broad as age great.
Now I can pass my working directory but as an honorable man and great Scribners as it did because of
wrong destination.
But I can change the destination part and direct and
is say wrong destination.
Now I can fix it to end with back up and it says Bekka.
Okay great.
So let's check the destination folder.
And I can see that in destination folder it is created timestamp folder with free media files.
Pretty amazing.
So now let's just around descript.
Again
OK.
And check destination Forder.
And we can see that we have time stamps folder here now.
Great.
I recommend you now to go through our script one time or to be sure that you understand everything.
So see you in next lecture.