WEBVTT

00:01.360 --> 00:08.620
As you have seen in previous examples, by default, the LHS command lists all the Non-hidden directory

00:08.620 --> 00:08.980
files.

00:08.980 --> 00:15.130
So sometimes this can be overkill, especially when you're just looking for information on a few files.

00:15.130 --> 00:22.210
So fortunately, the LHS command also provides a way for you to define a filter on the command line.

00:22.210 --> 00:29.140
So it uses the filter to determine which files or directories it should display in the output.

00:29.140 --> 00:36.700
So before using the filter command here, let's create some files to play with the via touch command

00:36.700 --> 00:36.940
here.

00:36.940 --> 00:40.720
So which you will learn touch command in more detail in next lecture.

00:40.720 --> 00:43.180
So let's actually by creating touch here.

00:43.180 --> 00:46.450
So let's create our file names.

00:46.450 --> 00:48.730
So my file.

00:50.810 --> 00:54.080
Uh, Oxley Academy.

00:56.150 --> 00:58.790
My document.

01:00.850 --> 01:02.710
Just a picture.

01:03.490 --> 01:04.570
And yeah, that's.

01:04.570 --> 01:07.090
I think that's okay enough.

01:07.360 --> 01:07.870
Yeah.

01:07.870 --> 01:13.960
And here and as you can see here, just the picture, my document, my file and Excel Academy is created

01:13.960 --> 01:14.440
here.

01:14.440 --> 01:17.500
So now let's actually create another.

01:19.080 --> 01:21.160
And another file, too.

01:21.180 --> 01:22.430
So torch.

01:25.800 --> 01:27.810
And in order to do that.

01:27.810 --> 01:34.470
So let's actually create the fall fell fill and full here.

01:34.560 --> 01:38.370
We also created this and fall fill, fill and full.

01:38.610 --> 01:44.010
So the filter command works as simple text matching strings.

01:44.010 --> 01:51.090
So include the filter after any command line parameters you want to use like this for here, for example,

01:51.090 --> 01:53.460
in this case we're going to use the long here.

01:53.460 --> 01:57.930
So now we're going to create, for example, my file here, right?

01:57.930 --> 01:59.640
My file.

02:00.780 --> 02:08.820
And as you can see here, we specified the name of the specific file as the filter.

02:08.820 --> 02:12.990
So the command only shows this file information.

02:12.990 --> 02:17.550
Sometimes you might not know the exact file name you're looking for.

02:17.550 --> 02:24.420
And the LS command also recognized standard wildcard characters and uses them to match patterns with

02:24.420 --> 02:25.080
the filter.

02:25.080 --> 02:25.690
So.

02:25.690 --> 02:29.650
So a question mark here represents one character.

02:29.650 --> 02:33.610
So ls a question mark represents one character here.

02:33.610 --> 02:35.440
So you can do like this.

02:36.070 --> 02:37.960
Let's actually create.

02:38.860 --> 02:43.420
So here, let's actually open our marker.

02:43.450 --> 02:44.350
Oops, Sorry.

02:45.650 --> 02:46.300
Yeah.

02:46.310 --> 02:49.930
Let's open our marker here.

02:49.940 --> 02:50.950
Yeah, Gromit.

02:50.960 --> 02:55.130
And now I want to write something on here.

02:55.130 --> 02:59.960
So firstly, as we created our files, we have file.

03:00.090 --> 03:00.620
File.

03:00.620 --> 03:01.880
Firstly, file.

03:02.740 --> 03:04.570
So then we have fell.

03:06.680 --> 03:08.900
And then we have Phil.

03:11.570 --> 03:14.660
And also lastly, we have full here.

03:16.180 --> 03:24.700
So let's actually what these characters and the sentences has common is that they always start with

03:24.700 --> 03:27.450
F and the last character.

03:27.460 --> 03:30.220
Last character is always l l here.

03:30.220 --> 03:35.530
So in this case, if we want to filter this, we can also do this.

03:35.530 --> 03:38.320
For example, let's yes here.

03:38.320 --> 03:41.080
So let's create a new file.

03:41.080 --> 03:43.360
In order to do that, we're going to do.

03:44.660 --> 03:45.140
Yeah.

03:45.350 --> 03:46.760
LZ, L here.

03:46.850 --> 03:47.190
Oops.

03:47.570 --> 03:49.710
LZ LSL.

03:49.730 --> 03:54.560
And as you can see here, we have file fill, full fill and other documents here.

03:54.560 --> 04:02.180
So if you want to just print those files, we need to do LZ here, Clear LSL.

04:02.180 --> 04:07.850
So we're going to we're going to do here ls l f question mark.

04:08.650 --> 04:11.170
And fill or LL here.

04:11.170 --> 04:14.620
And as you can see, here we are.

04:14.620 --> 04:19.240
This question mark, as I said earlier, is represents one character.

04:19.240 --> 04:21.400
So this question mark represents one character.

04:21.490 --> 04:22.330
We don't know.

04:22.330 --> 04:25.720
But we want to search these terms here, as you can see here.

04:25.720 --> 04:29.530
So here we added the question mark here.

04:29.530 --> 04:40.510
So we added here f question mark and LL So this tells us that start with start for characters that start

04:40.510 --> 04:46.240
with the F and end with the last two characters has two L's on it.

04:46.240 --> 04:49.240
So we just want to filter this here.

04:49.360 --> 04:53.920
So we also have the asterisks to represent any number of characters.

04:54.640 --> 04:59.830
But here, for example, we can also do let's actually delete this.

04:59.830 --> 05:01.210
Yeah, we can also.

05:01.210 --> 05:09.430
So here we had the my file, my document, just the picture and let's create another here touch ox and

05:09.430 --> 05:10.960
my Oxley.

05:12.200 --> 05:13.010
Pouch.

05:14.350 --> 05:18.620
Touch my Linux and LZ here.

05:18.630 --> 05:19.350
Clear.

05:19.380 --> 05:24.300
Firstly, LZ, and as you can see here, my document, my file, my Linux, my Excel.

05:25.020 --> 05:28.350
So in order to do that, we're going to do here.

05:28.920 --> 05:30.500
LZ Oops.

05:30.510 --> 05:32.690
Yeah, LZ, L here.

05:32.700 --> 05:35.100
So we're going to do so, as you know, here.

05:35.100 --> 05:38.460
So we have the my.

05:39.760 --> 05:41.200
My document.

05:45.780 --> 05:48.840
Also we have here my file.

05:54.590 --> 05:56.810
Also we have my Linux.

06:01.950 --> 06:03.750
Also lastly my Oxley.

06:10.060 --> 06:10.720
Here.

06:10.720 --> 06:17.500
So now in order to search these files, as you can see here with the LSL command, we got like a wide

06:17.740 --> 06:18.790
range of files.

06:18.790 --> 06:24.310
But if we want to filter these files and the filter, that's.

06:25.200 --> 06:29.840
Filter names that start with the my here m I or other characters.

06:29.850 --> 06:31.530
We're going to do just this here.

06:31.530 --> 06:40.350
So let's get here and we will do my and this asterisk and here it will show us files that start with

06:40.350 --> 06:47.730
my so we can also do that with this here so lsl f and asterisk instead of here.

06:47.730 --> 06:50.640
And as you can see here, we got the same result.

06:51.510 --> 06:53.770
But actually, these are not the same.

06:53.790 --> 07:03.540
Of course, if, for example, let's create another file, touch file fail, and here we will enter

07:03.540 --> 07:04.950
our old command.

07:04.950 --> 07:06.150
So clear.

07:06.300 --> 07:07.230
Clear.

07:08.040 --> 07:12.030
LSL And as you can see, we have failed fall field.

07:13.640 --> 07:15.020
Fill and full.

07:15.020 --> 07:16.550
And here we're going to do.

07:18.420 --> 07:26.400
Yeah, we will do the previous comment here F and here WL here and as you can see we don't we don't

07:26.400 --> 07:32.250
see our fail here because fail last two characters is not WL here.

07:32.250 --> 07:34.890
So that's it with our example here.

07:34.980 --> 07:41.280
In next lecture I will the talk about the handling and creating files in Linux.

07:41.280 --> 07:42.390
So see you later.
