Linux Survival
Search
Primary Menu
Skip to content
Home
Blog
Testimonials
Linux Links
Command List
Contact
Search for:
Linux Survival
The command used to find files is called, appropriately enough, "find". But even though the name is easy to remember, the syntax is quite treacherous. A typical "find" command looks something like this: find ~ -name "poem*" This example is shown at right. The first argument you specify is the directory to start the search from. If "find" always searched the entire tree on a system, it would be very inefficient, so this first argument allows you to limit your search. In the above example, it will be started from your home directory (~) and will then search the entire tree under it. The "-name" option says that you are searching for a file's name. At first, this might seem obvious and redundant, but you have to understand just how powerful the "find" command is. You can use it to search for files of a particular size, date, owner, and a variety of other criteria. The argument to "-name" can be as simple as "poem" if you know that is the exact name of the file. But, if you're not sure whether the file is called "poem", "poems", or even "poem-favorite", then you can use a wildcard, like '*'. However, when you use a wildcard, you need to surround the argument in quotes. If you don't, you will receive a rude error message. Now we'll give you a hint that will save you a bit of typing. Your first try at using this command to find joke files in Greg's home directory would probably begin with find ~jester ... But there is a simpler way. Remember the '..' symbol which is used to represent a parent directory (e.g. "cd ..")? Well, there is a similar symbol which represents your current directory. It is just a single '.'. So, since you are already in the "~jester" directory, you can begin your command with "find .". Whew! That was a heck of a lot of explanation for just one command. Click the right arrow.
Page 40
Where learning Linux is easy
Module 1 Introduction
Directory Structure
List Directory
View File Contents
Create Directory
Move and Rename File
Change Directory
Get Current Location
Quiz 1
End of Module 1
Module 2 Introduction
Pathnames
Copy File
Remove File
Remove Directory
File Security
Change File Permissions
Wildcards
Groups Memberships
Quiz 2
End of Module 2
Module 3 Introduction
Home Directories
Manual Pages
User Information
Find File
Concatenate Files
Redirect Output
Print
Print Job Status
Cancel Print Job
Quiz 3
End of Module 3
Module 4 Introduction
Copy Tree
Disk Space
Remove Tree
Process Status
Pipe Output
Pattern Matching
Kill Process
Quiz 4
Conclusion