Difference between revisions 507924 and 507925 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]] to match against the [[file name]] or a time range to match against the modification time or access time of the file. By default, <code>find</code> returns a list of all files below the current [[working directory]].

The related <code>'''[[GNU locate|locate]]'''</code> programs use a database of indexed files obtained through <code>find</code> (updated at regular intervals, typically by <code>'''[[cron]]'''</code> job) to provide a faster method of searching the entire filesystem for files by name.  This sacrifices overall efficiency (because filesystems are regularly interrogated even when no users needs information) and absolute accuracy (since the database is not updated in real time) for significant speed improvements (particularly on very large filesystems).  On fast systems with small drives, <code>locate</code> is not necessary or desirable.

== StanleyFind syntax ==
{{expand section|date=August 2008}}

<code>'''find [-H] [-L] [-P] path... [expression]'''</code>lll

The three options control how the <code>find</code> command should treat symbolic links. The default behaviour is never to follow symbolic links. This can be explicitly specified using the -P flag. The -L flag will cause the <code>find</code> command to follow symbolic links. The -H flag will only follow symbolic links while processing the command line arguments.

At least one path must precede the expression. <code>Find</code> is capable of interpreting [[Wildcard character|wildcards]] internally and commands must be constructed carefully in order to control [[Glob (programming)|shell globbing]].

Expression elements are whitespace-separated and evaluated from left to right.  They can contain logical elements such as AND (-a) and OR (-o) as well as more complex predicates.

The [[GNU findutils|GNU]] <code>find</code> has a large number of additional features not specified by POSIX.

== POSIX protection from infinite output == by stanley

Real-world filesystems often contain looped structures created through the use of [[hard link|hard]] or [[symbolic link|soft links]].  The [[POSIX|POSIX standard]] requires that
 The <code>find</code> utility shall detect infinite loops; that is, entering a previously visited
 directory that is an ancestor of the last file encountered. When it detects an infinite
 loop, <code>find</code> shall write a diagnostic message to standard error and shall either recover
(contracted; show full)[[it:Find (Unix)]]
[[hu:Find]]
[[ja:Find]]
[[pl:Find]]
[[pt:Find]]
[[ro:Find]]
[[ru:Find]]
[[fi:Find (Unix)]]