Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,210 --> 00:00:05,430
In this section we're going to be talking about wild cards and this is where things start to get really
2
00:00:05,430 --> 00:00:07,250
interesting and fun with Linux.
3
00:00:07,260 --> 00:00:11,110
This is where you can start to see why Linux is really powerful.
4
00:00:11,550 --> 00:00:15,020
And this section we're going to be covering what wild cards are.
5
00:00:15,060 --> 00:00:21,110
Get a good understanding of what the concept is and see some practical examples.
6
00:00:21,160 --> 00:00:28,040
Wild Cards also known as globbing or characters or strings used for pattern matching.
7
00:00:28,440 --> 00:00:34,440
Usually we use those with command line to increase the flexibility of searches or commands that we are
8
00:00:34,440 --> 00:00:35,790
issuing.
9
00:00:35,790 --> 00:00:40,800
So what does it mean when I say the characters or strings.
10
00:00:40,940 --> 00:00:43,260
Here are some examples.
11
00:00:43,260 --> 00:00:50,510
The first is the asterisk character and it's used to match zero or all characters.
12
00:00:50,940 --> 00:00:56,510
The second is the question mark is used to match exactly one character.
13
00:00:57,030 --> 00:01:02,850
The third is a bracket and it's used to match any of the characters enclosed in the bracket.
14
00:01:03,000 --> 00:01:10,860
And the last is the escape character and it's used to escape the above characters so if for example
15
00:01:10,860 --> 00:01:14,370
in my search term I am looking for a bracket.
16
00:01:14,370 --> 00:01:18,480
I will precede that with a backslash.
17
00:01:18,480 --> 00:01:21,070
Let's see some practical examples.
18
00:01:21,120 --> 00:01:26,560
I've created a number of files that were very commonly see when we're doing ethical hacking engagements.
19
00:01:26,940 --> 00:01:31,110
Feel free to download these files or you can create them yourself.
20
00:01:31,110 --> 00:01:32,130
These files are empty.
21
00:01:32,130 --> 00:01:36,100
They're just created for the purpose of this exercise.
22
00:01:36,240 --> 00:01:41,460
What we're looking at here is a number of files that correspond to different network ranges and network
23
00:01:41,490 --> 00:01:42,810
addresses.
24
00:01:42,810 --> 00:01:49,560
So the assumption is that I've been doing unethical hack for a company and I generated through our my
25
00:01:49,560 --> 00:01:55,920
assessment and number of files from and map and a number of text files that I've written notes into
26
00:01:56,670 --> 00:02:01,440
as you can see we have different names and different extensions to these files.
27
00:02:01,440 --> 00:02:08,430
So we have files Dotti XTi we have files and map we have files thought and map and we're going to see
28
00:02:08,430 --> 00:02:11,580
what the difference between these two files are later on.
29
00:02:11,820 --> 00:02:15,420
And I have files that and would not auditee.
30
00:02:15,800 --> 00:02:21,750
The first thing I want to do is I want to back up all these files before I start removing or moving
31
00:02:21,750 --> 00:02:23,880
the files around just in.
32
00:02:24,060 --> 00:02:28,960
And I can do that using the command that we saw in the previous exercise.
33
00:02:29,040 --> 00:02:38,510
So I'm just going to type tie C F to create a file the name of the file will be back up to space star.
34
00:02:38,640 --> 00:02:46,560
This is the first wildcard I'm using started as we've seen before means match zero or all characters.
35
00:02:46,560 --> 00:02:55,660
So in this case I'm telling Todd to create a tar file and include and everything in the current directory.
36
00:02:55,680 --> 00:03:01,570
Once that's done let me verify very quickly the content and I can do that using the time T.F. command.
37
00:03:01,620 --> 00:03:02,680
And here we go.
38
00:03:02,700 --> 00:03:04,920
I get all the files backed up.
39
00:03:04,920 --> 00:03:05,660
Fantastic.
40
00:03:05,730 --> 00:03:10,410
So now I can start cleaning up my directory and reorganizing it.
41
00:03:10,740 --> 00:03:17,960
I'm going to create a directory called Notes and I want to move all the notes files into that directory.
42
00:03:17,970 --> 00:03:25,360
It's good practice before I delete or I move any file especially before I delete any files to do.
43
00:03:25,370 --> 00:03:32,190
And I'll ask command if I'm using any wildcards and I do that just to make sure that my command works
44
00:03:32,190 --> 00:03:36,560
correctly and I'm not accidently deleting far as I shouldn't be deleting.
45
00:03:37,230 --> 00:03:45,180
So now if I do not know there's that not only the notes files are listed but also the notes directory
46
00:03:45,180 --> 00:03:52,770
that I just created a fine I'll use the asterisk wildcard and I try to move notes asterisk into the
47
00:03:52,770 --> 00:03:54,500
notes directory.
48
00:03:54,690 --> 00:04:02,010
The command will attempt to move everything that starts with the word notes followed with whatever.
49
00:04:02,340 --> 00:04:06,750
So now it's 10 or 11 including the notes directory.
50
00:04:06,840 --> 00:04:12,900
And what that means is that I'll be attempting to move the notes directory into itself.
51
00:04:12,900 --> 00:04:15,330
This will generate an error for me.
52
00:04:15,330 --> 00:04:20,280
But if you look a little bit closer you'll see that all the notes files have a hyphen in the middle
53
00:04:20,640 --> 00:04:28,290
before the digit so it's notes dashed then notes that 11 or hyphen 11 notes hyphen 12 and so on.
54
00:04:28,290 --> 00:04:30,760
So let me see what happens if I do.
55
00:04:30,790 --> 00:04:33,650
As nodes HIF and star.
56
00:04:33,960 --> 00:04:34,470
Excellent.
57
00:04:34,470 --> 00:04:39,950
So this command lists all the notes Faas excluding the notes directory's.
58
00:04:39,960 --> 00:04:46,530
Now I can safely use my move command knowing that I'm only going to be moving the files into the directory
59
00:04:46,650 --> 00:04:55,770
without trying to move the notes directory into itself and I can do that typing move or M.V. notes dash
60
00:04:55,830 --> 00:04:58,410
start for all the notes file.
61
00:04:58,410 --> 00:05:01,110
So this is going to go with notes.
62
00:05:01,160 --> 00:05:08,930
Then the XTi and nod's 24 dot auditee so it doesn't matter what the digit is it doesn't matter what
63
00:05:08,930 --> 00:05:10,600
the extension is.
64
00:05:10,760 --> 00:05:15,850
And it doesn't matter what follows the notes hyphen and I hit enter.
65
00:05:16,130 --> 00:05:18,760
And I do an S on the notes directory.
66
00:05:18,770 --> 00:05:19,610
And here we go.
67
00:05:19,610 --> 00:05:24,020
I managed to successfully move all my notes into the notes directory.
68
00:05:24,020 --> 00:05:24,790
Excellent.
69
00:05:24,800 --> 00:05:30,810
Let me clear the screen and I do as again here's what I want to do.
70
00:05:30,810 --> 00:05:36,400
Now I want to get rid of all the ten ten hundred files.
71
00:05:36,450 --> 00:05:41,230
Here's a scenario I did a scan on this network and no results were found.
72
00:05:41,360 --> 00:05:45,150
So I don't need to be keeping these files I just want to remove them.
73
00:05:45,170 --> 00:05:53,260
The challenging bit here though is that I have turned up 10 to 100 thought zero Dot T XTi.
74
00:05:53,450 --> 00:06:00,980
And then I have the tender turned up 100 without the zero g and map and the third one is dot and map.
75
00:06:00,980 --> 00:06:04,660
So what's the simplest way to remove these three files.
76
00:06:04,730 --> 00:06:09,480
Again I'm going to verify my command with L as before I'd move anything.
77
00:06:09,770 --> 00:06:19,670
Let me try and do s 10 dot dot 100 dot all that was simple enough so that listed the three files for
78
00:06:19,670 --> 00:06:20,230
me.
79
00:06:20,570 --> 00:06:27,380
So now for that to work with the remove commands I need to add the asterisk to tell the command to look
80
00:06:27,380 --> 00:06:31,910
for anything after the 100 dot.
81
00:06:32,360 --> 00:06:37,380
I can verify this with a standard 10 to 100 dot asterisk.
82
00:06:37,490 --> 00:06:40,140
And again that listed out the three fives.
83
00:06:40,250 --> 00:06:41,900
Perfect.
84
00:06:41,900 --> 00:06:45,550
Now all I need to do is replace the L S with.
85
00:06:45,870 --> 00:06:51,690
I am great I'll clear the screen again an L S.
86
00:06:51,740 --> 00:06:53,330
Now here's what I want to do.
87
00:06:53,330 --> 00:06:57,470
I want to move all the files into one that actually remember.
88
00:06:57,500 --> 00:07:02,630
I have two different extensions G and map and map.
89
00:07:02,750 --> 00:07:05,610
We'll see how we're going to manage that.
90
00:07:05,630 --> 00:07:12,890
First I want to create a directory called and map once that's done I'm going to try and list all the
91
00:07:12,930 --> 00:07:14,570
and map files.
92
00:07:14,570 --> 00:07:17,900
I'm going to try as asterisk Daut and map
93
00:07:24,720 --> 00:07:31,270
that didn't actually work so that listed all the flaws that start with anything with the extension dot
94
00:07:31,360 --> 00:07:35,060
and map what that missed out on the G and map.
95
00:07:35,250 --> 00:07:38,650
Whatever if I do I'll start a dot G and map
96
00:07:42,040 --> 00:07:43,980
that unfortunately it doesn't work either.
97
00:07:43,980 --> 00:07:49,080
So it only lists the files with the G and map extension.
98
00:07:49,120 --> 00:07:50,110
That's my challenge.
99
00:07:50,120 --> 00:07:53,500
Now I want a command that lists both.
100
00:07:54,070 --> 00:08:02,280
So the command should say list whatever dot and map and Dot G and map how can I do that.
101
00:08:02,350 --> 00:08:09,580
What if I put another asterisk after the dot so l as asterisk dot asterisk and map.
102
00:08:09,670 --> 00:08:10,170
Excellent.
103
00:08:10,180 --> 00:08:11,290
This worked.
104
00:08:11,350 --> 00:08:18,160
So what this commanded is that it listed anything dot anything.
105
00:08:18,160 --> 00:08:20,990
Followed immediately with map.
106
00:08:21,130 --> 00:08:24,180
So for example I had a file with extension thought.
107
00:08:24,250 --> 00:08:28,480
1 2 3 4 5 6 and map that would have been listed as well.
108
00:08:28,810 --> 00:08:33,610
So now that my command works all I need to do again is replace the L S with M.V.
109
00:08:49,570 --> 00:08:56,740
and I do s on the end map directory and he would go on my and my files are in one directory and clear
110
00:08:56,740 --> 00:08:57,880
the screen.
111
00:08:57,880 --> 00:09:00,980
Now things will start to get a little bit more interesting.
112
00:09:01,390 --> 00:09:09,550
I have different network ranges I have that 10 ten top 10 10 that turned up 11 and 10 out 10 12 I'm
113
00:09:09,550 --> 00:09:14,680
going to call that the 10s range because it's 10 11 12.
114
00:09:15,130 --> 00:09:22,410
I also have the 20s range so tender Tandou 23 24 and 25.
115
00:09:22,420 --> 00:09:26,160
I'm going to call those the 20s range and last.
116
00:09:26,230 --> 00:09:33,310
I have the tender Tom two hundred range two or six or seven and two or eight while I want to do now
117
00:09:33,520 --> 00:09:38,140
is move all these different ranges into different folders.
118
00:09:38,410 --> 00:09:53,960
So I'm going to start by creating the different directories I'll create the tens twenties and to hundreds.
119
00:09:53,970 --> 00:09:55,430
Now let me try the first command.
120
00:09:55,440 --> 00:10:01,090
I'm going to do it as 10.0 and not one that was easy enough.
121
00:10:01,260 --> 00:10:02,430
That lasted for me.
122
00:10:02,440 --> 00:10:07,400
The 10s range than the 10 the 10 11 12.
123
00:10:07,440 --> 00:10:13,920
So now if I do understand that one asterisk it should produce the same result.
124
00:10:13,920 --> 00:10:14,510
There we go.
125
00:10:14,520 --> 00:10:17,440
And all I need to do now is move.
126
00:10:17,970 --> 00:10:25,260
Change the L S to move and add the directory name I list the contents of the directory and all the files
127
00:10:25,260 --> 00:10:27,020
are moved.
128
00:10:27,040 --> 00:10:33,660
Now what happens if I try the same thing with the 20s.
129
00:10:33,670 --> 00:10:34,470
Let's see.
130
00:10:34,470 --> 00:10:36,940
I'll ask them then that tended to.
131
00:10:37,260 --> 00:10:39,630
Oh that doesn't look like it's going to work.
132
00:10:39,750 --> 00:10:45,360
At least the 20s and the two 100s because they both start with two.
133
00:10:45,390 --> 00:10:52,710
So if I do understand the to star I'm going to get both ranges.
134
00:10:53,070 --> 00:10:54,780
So what do I do now.
135
00:10:55,800 --> 00:10:57,720
Remember the question Mike.
136
00:10:57,840 --> 00:11:02,660
So the asterisk matched zero or all characters.
137
00:11:02,790 --> 00:11:06,530
The question mark matches exactly one character.
138
00:11:07,110 --> 00:11:13,280
So now if I put the question mark after the two and I add the extension dot whatever.
139
00:11:13,590 --> 00:11:17,250
I'll only get a listing of the 20s.
140
00:11:17,250 --> 00:11:17,740
Why.
141
00:11:17,760 --> 00:11:21,830
Because the question mark replaces only one digit after the two.
142
00:11:21,870 --> 00:11:25,250
In this case 23 24 and 25.
143
00:11:25,310 --> 00:11:27,520
What if I wanted to list the hundreds.
144
00:11:27,670 --> 00:11:28,830
Simple.
145
00:11:29,010 --> 00:11:31,090
I put another question like.
146
00:11:31,290 --> 00:11:39,030
So now I'm telling as to list 10 to attend attended two digit digit dot whatever.
147
00:11:39,240 --> 00:11:39,840
Great.
148
00:11:39,840 --> 00:11:40,890
Here we go.
149
00:11:40,920 --> 00:11:43,970
Now all I need to do is change the l s and to move.
150
00:11:44,190 --> 00:11:46,390
I move the 20s in to one directory
151
00:11:55,760 --> 00:12:05,300
and I do as again now all that's left are the two hundreds Obviously I could repeat the old commands
152
00:12:05,480 --> 00:12:11,220
and I can do two question marks but that's not the fastest way to do that.
153
00:12:11,240 --> 00:12:17,450
If you look at the contents of the file all that's left are the text files and they all start with some
154
00:12:17,450 --> 00:12:18,060
digits.
155
00:12:18,080 --> 00:12:22,500
Dorothy XTi now because all that's left are the two 100s.
156
00:12:22,550 --> 00:12:29,280
I know that I want to move all of these into the 200 folder.
157
00:12:29,470 --> 00:12:35,880
So the simplest process way to do that is replace the network ranges with a star or asterisk.
158
00:12:36,040 --> 00:12:45,790
Telling my move command to move everything that ends with a dot the XTi and I put the folder name and
159
00:12:45,790 --> 00:12:49,240
done I do as a double check.
160
00:12:49,240 --> 00:12:49,960
Good stuff.
161
00:12:50,080 --> 00:12:51,600
Here's a quick bonus for you.
162
00:12:51,610 --> 00:12:53,700
I'm going to try the three commands.
163
00:12:56,370 --> 00:12:58,120
It doesn't exist.
164
00:12:58,200 --> 00:13:04,830
So we're going to use what we just learned in the previous sections to install the command AAPT get
165
00:13:04,830 --> 00:13:10,170
install three wait for a few seconds for it to install.
166
00:13:10,170 --> 00:13:12,640
Now if I try again the command exists.
167
00:13:12,720 --> 00:13:19,730
So the three command shows you the content of any directory and a more graphical organized format.
168
00:13:19,830 --> 00:13:23,090
I want to see the content of the current directory that I'm in.
169
00:13:23,370 --> 00:13:24,360
What do I do.
170
00:13:24,390 --> 00:13:26,330
We've seen this before.
171
00:13:26,460 --> 00:13:29,290
Three space dot.
172
00:13:29,730 --> 00:13:32,990
And it shows me this neat organized output.
173
00:13:33,090 --> 00:13:37,370
I can verify that understands I have the tens range on there to hundreds.
174
00:13:37,470 --> 00:13:46,770
Same twenty's same unmap has all the and mapped files and all the data XTi nodes and not all the nodes
175
00:13:46,800 --> 00:13:49,600
are in my notes directory.
176
00:13:49,650 --> 00:13:54,170
Now that looks much more organized than it looked before hazier mission for the section.
177
00:13:54,180 --> 00:13:57,690
If you haven't been following up with what I've done please do it.
178
00:13:57,690 --> 00:13:58,920
Practice it.
179
00:13:58,930 --> 00:14:04,350
It might sound like it's a lot of information but with practice it will get easier and easier and you'll
180
00:14:04,350 --> 00:14:10,300
notice that almost 90 percent of the time your usage will be limited to asterisk.
181
00:14:10,560 --> 00:14:12,540
So practice a little bit with that.
182
00:14:12,750 --> 00:14:14,100
Create these files.
183
00:14:14,100 --> 00:14:18,910
Repeat the exercises if you haven't done so already following up with the video so we can move into
184
00:14:18,930 --> 00:14:20,230
the next section.
18440
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.