Chapter 9. Finding Files with find
How to Use find
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:
%findpath 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:
-namefilenameFind files with the given
filename. This is the most commonly used operator.filenamemay include wildcards, but if it does, they must be quoted to prevent the shell from interpreting the wildcards.-permmodeFind files with the given access mode. You must give the access mode in octal.
-typecFind the files of the given type, specified by
c.cis a one-letter code; for example,ffor a plain file,bfor a block special file,lfor a symbolic link, and so forth.-usernameFind files belonging to user
name.namemay also be a user ID number.-groupnameFind files belonging to group
name.namemay also be a group ID number.-sizenFind files that are
nblocks long. A block usually equals 512 bytes. The notation+nsays “find files that are overnblocks long.” The notationncsays “find files that arencharacters long.” Can you guess what+ncmeans?-inumnFind files with the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access