Difference between revisions 508019 and 508020 on knwiki

{{other uses}}
{{unreferenced|date=September 2013}}
{{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(contracted; show full)<code>-empty</code> or <code>-name</code>.

 find /foo -delete  # this deletes '''all''' in /foo

===Search for a string===
This command will search for a string in all files from the /tmp directory and below:
<source lang="bash">
 $ find /tmp 
=-type f -exec grep 'search string' '{}' /dev/null \+
</source>
The <tt>[[/dev/null]]</tt> argument is used to show the name of the file before the text that is found. Without it, only the text found is printed.  An equivalent mechanism is to use the "-H" or "--with-filename" option to grep:
<source lang="bash">
 $ find /tmp -type f -exec grep -H 'search string' '{}' '+' 
</source>
(contracted; show full)*{{man|1|find||search for files in a directory hierarchy}}
*[http://www.gnu.org/software/findutils/manual/html_mono/find.html Official webpage for GNU find]

{{Unix commands}}

[[Category:Searching]]
[[Category:Standard Unix programs]]
[[Category:Unix SUS2008 utilities]]