Name

find [directories] [expression] — findutils

Synopsis

/usr/bin stdin stdout - file -- opt --help --version

The find command searches one or more directories (and their subdirectories recursively) for files matching certain criteria. It is very powerful, with over 50 options and, unfortunately, a rather unusual syntax. Here are some simple examples that search the entire file system from the root directory:

Find a particular file named myfile:

$ find / -type f -name myfile -print

Print all directory names:

$ find / -type d -print

Useful options

-namepattern

-pathpattern

-lnamepattern

-inamepattern

-ipathpattern

-ilnamepattern

The name (-name), pathname (-path), or symbolic link target (-lname) of the desired file must match this shell pattern, which may include shell wildcards *, ?, and []. Paths are relative to the directory tree being searched. The -iname, -ipath and -ilname options are the same as -name, -path, and -lname, respectively, but are case-insensitive.

-regex regexp

The path (relative to the directory tree being searched) must match the given regular expression.

-type f|d|l|b|c|p|s

Locate only plain files (f), directories (d), symbolic links (l), block devices (b), character devices (c), named pipes (p), or sockets (s).

-atime N

-ctime N

-mtime N

File was last accessed (-atime), last modified (-mtime), or had a status change (-ctime) exactly N*24 hours ago. Use +N for “greater than N,” or -N for “less than N.”

-amin N

-cmin N

-mmin N

File was last accessed (-amin), last modified ( ...

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.