Go to the first, previous, next, last section, table of contents.
Here is how to control which directories find
searches, and how
it searches them. These two options allow you to process a horizontal
slice of a directory tree.
- Option: -maxdepth levels
-
Descend at most levels (a non-negative integer) levels of
directories below the command line arguments. `-maxdepth 0' means
only apply the tests and actions to the command line arguments.
- Option: -mindepth levels
-
Do not apply any tests or actions at levels less than levels (a
non-negative integer). `-mindepth 1' means process all files
except the command line arguments.
- Option: -depth
-
Process each directory's contents before the directory itself. Doing
this is a good idea when producing lists of files to archive with
cpio
or tar
. If a directory does not have write
permission for its owner, its contents can still be restored from the
archive since the directory's permissions are restored after its contents.
- Action: -prune
-
If `-depth' is not given, true; do not descend the current
directory. If `-depth' is given, false; no effect. `-prune'
only affects tests and actions that come after it in the expression, not
those that come before.
For example, to skip the directory `src/emacs' and all files and
directories under it, and print the names of the other files found:
find . -path './src/emacs' -prune -o -print
- Option: -noleaf
-
Do not optimize by assuming that directories contain 2 fewer
subdirectories than their hard link count. This option is needed when
searching filesystems that do not follow the Unix directory-link
convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
points. Each directory on a normal Unix filesystem has at least 2 hard
links: its name and its `.' entry. Additionally, its
subdirectories (if any) each have a `..' entry linked to that
directory. When
find
is examining a directory, after it has
statted 2 fewer subdirectories than the directory's link count, it knows
that the rest of the entries in the directory are non-directories
(leaf files in the directory tree). If only the files' names need
to be examined, there is no need to stat them; this gives a significant
increase in search speed.
Go to the first, previous, next, last section, table of contents.