How to Use find
Delving Through a Deep Directory Tree
Don't Forget -print
Looking for Files with Particular Names
Searching for Old Files
Be an Expert on find Search Operators
The Times That find Finds
Exact File-Time Comparisons
Running Commands on What You Find
Using -exec to Create Custom Tests
Custom -exec Tests Applied
Finding Many Things with One Command
Searching for Files by Type
Searching for Files by Size
Searching for Files by Permission
Searching by Owner and Group
Duplicating a Directory Tree
Using "Fast find" Databases
Wildcards with "Fast find" Database
Finding Files (Much) Faster with a find Database
grepping a Directory Tree
lookfor: Which File Has That Word?
Using Shell Arrays to Browse Directories
Finding the (Hard) Links to a File
Finding Files with -prune
Quick finds in the Current Directory
Skipping Parts of a Tree in find
Keeping find from Searching Networked Filesystem
The utility find is one of the most useful and important of the Unix utilities. It finds files that match a given set of parameters, ranging from the file's name to its modification date. In this chapter, we'll be looking at many of the things it can do. As an introduction, here's a quick summary of its features and basic operators:
% find path operators
where path is one or more directories in which find will begin to search and operators (or, in more customary jargon, options) tell find which files you're interested in. The operators are as follows:
You might want to take some action on files that match several criteria. So we need some way to combine several operators:
Another group of operators tells find what action to take when it locates a file:
% find . -name "*.o" -exec rm -f {} \;
tells find to delete any files whose names end in .o.
A last word: find is one of the tools that vendors frequently fiddle with, adding (or deleting) a few operators that they like (or dislike). The GNU version, in particular, has many more. The operators listed here should be valid on virtually any system. If you check your manual page, you may find others.
-- ML
Copyright © 2003 O'Reilly & Associates. All rights reserved.