Wild cards what are wild cards.
Just as his name sees the wild card meaning if you play cards
and you know in poker or blackjack they do pick a card like 10 or nine with the card and you could match
it to any of the card to make your flash trail or whatever that you like.
So that is kind of a wild card.
So just like that in Linux we use wild cards to get the output that we are looking for a wild card is
a character.
Now this is a definition right from the Linux dictionary that can be used as a substitute for any of
a class of characters in a search.
So there are many wildcards but the most basic ones I have listed here there are three.
The first one is the one I use most of the time is asterisk which is also referred to as a star.
A star represents 0 or more characters.
Anything that matches that star placeholder.
We'll look into that in a moment.
And we actually use the star wildcard in our Linux machine.
Now we have a question mark represents a single character.
So if you have a filename text and you are looking for any files that has the word text and you could
use t e instead of X you could just put questionmark in there and then t that means what ever files
that had t e.
Doesn't matter what's inside of the X.
And the last letter is x t.
That don't work.
The third one we have brackets which represents a range of characters.
So it's better if we look at one Linux machine to understand them more deeply and bring up my machine
real quick where we go right here and log.
Den Harbor's is myself and I'm in my home directory of course.
Now right now these are the files and directories and exist in my home directory.
I want to create 9 files that has a name.
Let's say ABC 1 and x y z and then same thing instead of one.
It just increments the number two three four five six.
I could do this touch a b c d 1 dash x y z one time then hit up arrow key again change wanted to change
it to 3 and keep going.
But don't you think it's cumbersome and tedious is right.
So we use wild card to perform that task because we're going to create 9 files.
So it's just a practice that we're doing for 9 files.
Trust me.
In corporate environment you're probably going to have to create thousands of miles what are you going
to do you're going to just hit up arrow key and or type it thousand times.
No that's not productive.
So then what do you do.
You use wildcards.
So first of all I'm going to do is I'm going to remove these files one by one again I removed a wild
card as well but let's create it first then I'll show you how I can remove it.
So I have two left.
Now I could use a wildcard to remove both in one shot.
Remore ABC wild card.
So what is telling it.
Remove everything that has a file name that starts with ABC and whatever that comes afterward you don't
care.
Just remove it a hit and turn.
That's my LTI and you'll see all those two files are gone.
Now I'm going to create nine files and to create nine falls apart use the command touch as you know
the touches a command to use and then there's a wild card and other wild card that's called curly braces.
So I was creating file ABC the curly braces one dot dot nine because I'm going to create 9 files.
So this curly braces 1.9 sellén create 9:4 that has the digit 1 through 9 and dash x y z.
When I run this command.
What do you think that I will have listed in my home directory.
I will have 9 files right here at the bottom you'll see I have nine files.
Awesome right.
This is what you want to do.
It is much more faster to do in the wild card as opposed to typing what I want.
So let's use the asterisk what I just want to list every filename that starts with a b c you do ABC
asterisked and you will have all the pause that starts with ABC.
I want to remove every file that starts with ABC.
You could remove one by one.
ABC 1 and so on and so forth.
Again very cumbersome don't do it.
You are a system administrator.
You are smart folks will use the commands one by one.
What do you use.
You'd use a wildcard.
So you'll do a b c d or a B and do pastorate.
The reason I picked the four letters because if I just pick a and hit asterisk It will also remove any
other files in my home directory that starts with a and which I don't want to do it right now I don't
have any power so let's say if I create a touch a.
So now I have all the files and a.
So I just want to confirm I don't have a.
So I don't delete any file accidently.
So yes I don't have any father begins with a.
Other than these.
So if I just do remove a asterisk it will remove all the files that starts with hey let's check out
say all those files are gone.
Isn't that cool.
Yes it is.
I love this asterisk because I use it all the time.
I'm going to recreate those files again by hitting up arrow key.
That will return my last rant command.
Just confirm they are there.
Now what if I whined to remove everything that ends with x y z.
Same way remove.
But this time I'll put asterisk in front of x y z.
Hit enter.
All gone.
Also I'm going to recreate it just for the exercise of this lesson.
It created nine files.
Now we'll move on to the next wild card with a question mark.
The next question mark is telling it.
LS My question mark.
B C D pestering.
OK what am I asking here.
I'm asking is give me all the files that has what ever the character is the first as long as the other
characters has B C D and whatever comes afterwards.
These are the matching files because whatever the first character is whether it's a or not I don't care.
I just want to make sure I will get the listing of the files that has B C D in it.
And after the.
So that's how you use the question mark.
And the last one we have brackets bracket is going to tell me that.
Give me anything that has C or D letter in a file.
It's just that simple.
Either C either D either F or this and that.
So you put all that stuff that you're looking for inside of the bracket and you will have all those
files you see here.
And it went so fast I'm going to put it in more of put I want to see one time and you'll see it gave
me and it has a it has b every file that I'm getting has either has a or b either has a or b.
So that's how it works.
That's how wild card works.
OK now I want to get rid of all the files that has y x and y in it.
Awesome.
I have my wild card.
I'm not going to go into the one by one.
So this man is telling the show that go ahead and please delete all the files that has x and y in it
and X and Y has to be together of course.
So we do have these matching files x y and it will go ahead and delete it and all of them are gone.
So wild card not necessarily is used just for LS or remote.
You could use that any of the commands to see how you use it with all the commands we have learned so
far.
Try it tried with different commands.
If it doesn't work that's OK.
Go online Google it and try wild card wild card examples try them.
Familiar with them this will help you a lot in your job.
I promise you.