Difference between revisions 507858 and 507859 on knwiki

{{otheruses}}
{{lowercase|title=find}} 
The <code>'''find'''</code> program is a [[directory (file systems)|directory]] [[Search_engine_(computing)|search utility]] on [[Unix-like]] platforms. It searches through one or more directory [[tree (computing)|trees]] of a [[filesystem]], locating [[Computer file|file]]s based on some user-specified criteria. By default, <code>find</code> returns all files below the current [[working directory]]. Further, <c(contracted; show full)===Commands===
The previous examples created listings of results because, by default, <code>find</code> executes the '-print' action.   (Note that early versions of the <code>find</code> command had no default action at all; therefore the resulting list of files would be discarded, to the bewilderment of users.) 

 find . -name "my*" -type f -ls
This prints an extended file information.

===Search all directories===
 find /
 -type f -name "myfile" -type f -print
This searches every file on the computer for a file with the name ''myfile''. It is generally not a good idea to look for data files this way.  This can take a considerable amount of time, so it is best to specify the directory more precisely.  Some operating systems may mount dynamic filesystems that are not congenial to find.

===Search all but one directory subtree===
 find / -path excluded_folder -prune -o -type f -name myfile -print
This searches every folder on the computer except the subtree ''excluded_folder'' for a file with the name ''myfile''.  It will not detect directories, devices, links, doors, or other "special" filetypes.

===Specify a directory===
 find /home/weedly -name "myfile" -type f -print
This searches for files named ''myfile'' in the ''/home/weedly'' directory, the home directory for userid ''weedly''.  You should always specify the directory to the deepest level you can remember.

===Search several directories===
 find local /tmp -name mydir -type d -print
(contracted; show full)[[fr:Find]]
[[it:Find (Unix)]]
[[hu:Find]]
[[ja:Find]]
[[pl:Find]]
[[pt:Find]]
[[ru:Find]]
[[fi:Find (Unix)]]