Hey guys, welcome back. In this video we're gonna be discussing the "find" command, and
some practical uses for that command. So, first off I've got a directory here named 'lt" so
I'm going to remove everything from that directory, and then I'm going to change
directory into there and we've got nothing. So, to demonstrate how we're
going to use the find command I'm just gonna take a moment here and create a
bunch of files with very own uncreative names, so I'm going to use touch to do
this.
I'm also going to create some text files in here as well. So, if I run "ls" on
this directory we see I've got like 10-11 files, and that's not a lot. There are
going to be times you're gonna be working in really large directories, and
so you can use the find command to help navigate within those directories, but
for right now we've got basically some files that we can use the find command on. So, as
you can see I've got file types of two different extensions, .php and .txt. You can see that
some of the extensions are printed lowercase, some are in uppercase, and some
are in a combination of the two,
and this will help you understand the different things that the find command can do.
So, let's say first that I'm just looking for all .php files, so I'm gonna type this first. So,
first we've got the command which is find, the next parameter is going to be
the directory that you're going to be looking in, so we're gonna put one single ".",
because we're gonna be searching in this current directory. The next argument is
going to be "-type" and that's gonna be followed by a "f"
for file, and then "-name" and this is gonna be a name of the file
we're looking for. So, if we just put ".php" this isn't going to bring anything
because there's no file with that exact name. So, what we need to do is add the wild-card
asterisk character "*" and we hit enter, and it's gonna return all all files with this
exact extension, and this is case sensitive. So, as you'll notice it's only
returned files with the lowercase .php extension, which can be useful but let's
say that I wanna find all .php files
regardless of the case. This is essentially the same command. You're
gonna type "find . -type f -iname "*.php""
and the "i" just means that it is going to ignore case sensitivity. So,
if I run this command again you're now gonna see that I'm getting all .php file
extensions, lowercase, uppercase, and mixed combination of the two cases.