(This is the first part in a three part series. Read part two here.)
Introduction:
Among the tools you will use on a Linux system, few are more valuable than the find utility from findutils. Forget search bars: This is a more highly tailored search system that can help you find exactly what you’re looking for with great ease. It will also permit you to perform operations upon the files that you find, delete them, or just list them. If you do more than just browse the Internet with your Linux box, you need some sort of proficiency with find.
Basics:
Find, at its simplest, will list everything in the filesystem beneath your current directory. This includes files, directories, symbolic links, FIFOs, sockets, and more other crap than you probably care to know about. Over 95% of your usage is going to be finding files and directories, so we’ll focus there.
If you open up a terminal and type
cd
find
You’ll receive a list of everything in the filesystem below your current directory.
Let’s limit that some. Let’s search for files that end in mp3.
find -name '*.mp3'
But wait, I know I had a file that ended in .MP3, why didn’t it show up? Well, the -name test is case sensitive. -iname is not. Let’s do the same thing with iname.
find -iname '*.mp3'
Ahh, there it is.
I want to search my videos directory for the video of my friend’s birthday party. I know it was named Fred-something. Now I can introduce a directory in the search.
find ~/Videos/ -name '*Fred*'
Hah. Fred is silly.
Well, that’s the most basic that you’ll get with find, grasshopper. Now you must prove your skills to the sensei!
Well, sort of. You just have to wait for the next part of the series.
-LightningCrash
(This is the first part in a three part series. Read part two here.)