|
find
Search a folder hierarchy for filename(s) that meet a desired
criteria.
SYNTAX find [path...] [expression] DESCRIPTION find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence (see section OPERA TORS), until the outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file name. The first argument that begins with - ( ) , or ! is taken to be the beginning of the expression; any arguments before it are paths to search, and any arguments after it are the rest of the expression. If no paths are given, the current directory is used. If no expression is given, the expression `-print' is used. find exits with status 0 if all files are processed suc cessfully, greater than 0 if errors occur. EXPRESSIONS The expression is made up of options (which affect overall operation rather than the processing of a specific file, and always return true), tests (which return a true or false value), and actions (which have side effects and return a true or false value), all separated by operators. -and is assumed where the operator is omitted. If the expression contains no actions other than -prune, -print is performed on all files for which the expression is true. OPTIONS All options always return true. They always take effect, rather than being processed only when their place in the expression is reached. Therefore, for clarity, it is best to place them at the beginning of the expression. -daystart Measure times (for -amin, -atime, -cmin, -ctime,-mmin, and -mtime) from the beginning of today rather than from 24 hours ago. -depth Process each directory's contents before the directory itself. -follow Dereference symbolic links. Implies -noleaf. -help, --help Print a summary of the command-line usage of find and exit. -maxdepth levels Descend at most levels (a non-negative integer) levels of directories below the command line argu ments. `-maxdepth 0' means only apply the tests and actions to the command line arguments. 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. mount Don't descend directories on other filesystems. An alternate name for -xdev, for compatibility with some other versions of find. noleaf Do not optimize by assuming that directories con tain 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 filesys tems 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 subdirecto ries 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. -version, --version Print the find version number and exit. -xdev Don't descend directories on other filesystems. TESTS Numeric arguments can be specified as +n for greater than n, -n for less than n, n for exactly n. -amin n File was last accessed n minutes ago. -anewer file File was last accessed more recently than file was modified. -anewer is affected by -follow only if -follow comes before -anewer on the command line. -atime n File was last accessed n*24 hours ago. -cmin n File's status was last changed n minutes ago. -cnewer file File's status was last changed more recently than file was modified. -cnewer is affected by -follow only if -follow comes before -cnewer on the command line. -ctime n File's status was last changed n*24 hours ago. -empty File is empty and is either a regular file or a directory. -false Always false. -fstype type File is on a filesystem of type type. The valid filesystem types vary among different versions of Unix; an incomplete list of filesystem types that are accepted on some version of Unix or another is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K. You can use -printf with the %F directive to see the types of your filesystems. -gid n File's numeric group ID is n. -group gname File belongs to group gname (numeric group ID allowed). -ilname pattern Like -lname, but the match is case insensitive. -iname pattern Like -name, but the match is case insensitive. For example, the patterns `fo*' and `F??' match the file names `Foo', `FOO', `foo', `fOo', etc. -inum n File has inode number n. -ipath pattern Like -path, but the match is case insensitive. -iregex pattern Like -regex, but the match is case insensitive. -links n File has n links. -lname pattern File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not treat `/' or `.' specially. -mmin n File's data was last modified n minutes ago. -mtime n File's data was last modified n*24 hours ago. -name pattern Base of file name (the path with the leading direc tories removed) matches shell pattern pattern. The metacharacters (`*', `?', and `[]') do not match a `.' at the start of the base name. To ignore a directory and the files under it, use -prune; see an example in the description of -path. -newer file File was modified more recently than file. -newer is affected by -follow only if -follow comes before -newer on the command line. -nouser No user corresponds to file's numeric user ID. -nogroup No group corresponds to file's numeric group ID. -path pattern
"Instead of getting married again, I'm going to find a woman
I don't like and just give her a house." - Lewis
Grizzard
Related commands:
grep - Search file(s) for lines that match a given pattern
egrep - Search file(s) for lines that match an extended
expression
fgrep - Search file(s) for lines that match a fixed
string
gawk - Find and Replace text within file(s)
tr - Translate, squeeze, and/or delete characters