Difference between revisions 508010 and 508011 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)
 $ find . -name "file-containing-can't" -exec grep "can't" '{}' \; -print
</source>
===Search for all files owned by a user===
 find . -user <userid>

===Search in case insensitive mode===
 find . -iname 
''''MyFile'''*'

If the <code>-iname</code> switch is not supported on your system then workaround techniques may be possible such as:

 find . -name '[mM][yY][fF][iI][lL][e'''M''']['''y'''Y][f'''F''']['''i'''I]['''l'''L]['''e'''E]*'

This uses [[Perl]] to build the above command for you:

 echo "''''MyFile'''*'" |perl -pe 's/([a-zA-Z])/[\L\1\U\1]/g;s/(.*)/find . -name \1/'|sh

===Search files by size===
Example of searching files with size between 100 kilobytes and 500 kilobytes.
 find . -size +100k -a -size -500k
Example of searching empty files.
 find . -size 0k
Example of searching non-empty files.
(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]]