search for files in a directory hierarchy
|
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
|
-name pattern
Base of file name (the path with the leading directories removed) matches shell pattern pattern.
The metacharacters (`*', `?', and `[]') match a `.' at the start of the base name (this is a
change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and
the files under it, use -prune; see an example in the description of -path. Braces are not
recognised as being special, despite the fact that some shells including Bash imbue braces with a
special meaning in shell patterns. The filename matching is performed with the use of the
fnmatch(3) library function. Don't forget to enclose the pattern in quotes in order to protect
it from expansion by the shell.
|
expr1 -o expr2
Or; expr2 is not evaluated if expr1 is true.
expr1 -or expr2
Same as expr1 -o expr2, but not POSIX compliant.
|
expr1 expr2
Two expressions in a row are taken to be joined with an implied "and"; expr2 is not evaluated if
expr1 is false.
expr1 -a expr2
Same as expr1 expr2.
expr1 -and expr2
Same as expr1 expr2, but not POSIX compliant.
|
-mtime n
File's data was last modified n*24 hours ago. See the comments for -atime to understand how
rounding affects the interpretation of file modification times.
|
-size n[cwbkMG]
File uses n units of space. The following suffixes can be used:
`b' for 512-byte blocks (this is the default if no suffix is used)
`c' for bytes
`w' for two-byte words
`k' for Kilobytes (units of 1024 bytes)
`M' for Megabytes (units of 1048576 bytes)
`G' for Gigabytes (units of 1073741824 bytes)
The size does not count indirect blocks, but it does count blocks in sparse files that are not
actually allocated. Bear in mind that the `%k' and `%b' format specifiers of -printf handle
sparse files differently. The `b' suffix always denotes 512-byte blocks and never 1 Kilobyte
blocks, which is different to the behaviour of -ls.
|
ACTIONS
-delete
Delete files; true if removal succeeded. If the removal failed, an error message is issued. If
-delete fails, find's exit status will be nonzero (when it eventually exits). Use of -delete
automatically turns on the -depth option.
Warnings: Don't forget that the find command line is evaluated as an expression, so putting
-delete first will make find try to delete everything below the starting points you specified.
When testing a find command line that you later intend to use with -delete, you should explicitly
specify -depth in order to avoid later surprises. Because -delete implies -depth, you cannot
usefully use -prune and -delete together.
|