Difference between revisions 507951 and 507952 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) find /foo -type d -empty -delete

Delete files and directories (if empty) named <code>bad</code> 
 find /foo -name bad -delete

'''Warning''': <code>-delete</code> should be use with other operators such as
<code>-empty</code> or <code>-name</code>.

This will
 find /foo -delete  (this deletes '''all''' in <code>foo</code>
 find /foo -delete)

===Search for a string===
This command will search for a string in all files from the /tmp directory and below:

 find /tmp -exec grep "search string" '{}' /dev/null \; -print

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:
(contracted; show full)[[hu:Find]]
[[ja:Find]]
[[pl:Find]]
[[pt:Find]]
[[ro:Find]]
[[ru:Find]]
[[fi:Find (Unix)]]
[[uk:Find]]