Difference between revisions 507934 and 507935 on knwiki

{{other uses}}
{{lowercase|title=find}} 
In [[Unix-like]] and some other [[operating system]]s, <code>'''find'''</code> is a [[command-line utility]] that [[Search engine (computing)|searches]] through one or more [[directory tree]]s of a [[file system]], locates [[Computer file|file]]s based on some [[user (computing)|user]]-specified criteria and applies a user-specified action on each matched file. The possible search criteria include a [[pattern matching|pattern(contracted; show full)
 -name 'catalina.out' \) -size +300000k -a -size -5000000k`; do cat /dev/null > $file; done

The units should be one of [bckw], 'b' means 512-byte blocks, 'c' means byte, 'k' means kilobytes and 'w' means 2-byte words. The size does not count indirect blocks, but it does count blocks in sparse files that are not actually allocated.


===Operators ===
Operators can be used to enhance the expressions of find command. Operators are listed in order of decreasing precedence:

*'''( expr )''' Force precedence. 
*'''! expr''' True if expr is false. 
*'''-not expr''' Same as ! expr. 
*'''expr1 expr2''' And (implied); expr2 is not evaluated if expr1 is false. 
*'''expr1 -a expr2''' Same as expr1 expr2. 
*'''expr1 -and expr2''' Same as expr1 expr2. 
*'''expr1 -o expr2''' Or; expr2 is not evaluated if expr1 is true. 
*'''expr1 -or expr2''' Same as expr1 -o expr2. 
*'''expr1 , expr2''' List; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the value of the list is the value of expr2. 

 find . -name 'fileA_*' -or -name 'fileB_*'

This command searches files which name has prefix of "fileA_" or "fileB_" in current directory.

 find . -name 'foo.cpp' -not -path '.svn'

This command searches file with name "foo.cpp" in all subdirectories of current directory(current directory itself included) other than ".svn".

==See also==
*[[GNU locate]], a Unix search tool based on a prebuilt database therefore faster and less accurate than <code>find</code>
*[[mdfind]], a similar utility that utilizes metadata for [[Mac OS X]] and [[Darwin (operating system)|Darwin]]
*[[List of Unix programs]]
*[[List of DOS commands]]
*[[find (command)]], a DOS and Windows command that is very different from UNIX <code>find</code>
*[[findutils]]
*[[Tree (Unix)| tree]]
(contracted; show full)[[hu:Find]]
[[ja:Find]]
[[pl:Find]]
[[pt:Find]]
[[ro:Find]]
[[ru:Find]]
[[fi:Find (Unix)]]
[[uk:Find]]