cmd/find: Difference between revisions

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
m Woozle moved page Linux/commands/find to cmd/find without leaving a redirect: reorganizing command pages
No edit summary
Line 5: Line 5:
</hide>
</hide>
==About==
==About==
The '''find''' [[Linux]] [[Linux/commands|command]] searches directory trees for files whose directory information meets particular criteria.
The {{l/cmd|find}} [[cmd|command]] searches directory trees for files whose directory information meets particular criteria.


To search by content, use [[grep]].
To search by content, use [[grep]].
==Examples==
==Examples==
Find a file or folder named "kate" somewhere under the current folder:
Find a file or folder named "kate" somewhere under the current folder:
: <syntaxhighlight lang=bash>find -name kate</syntaxhighlight>
: <syntaxhighlight inline lang=bash>find -name kate</syntaxhighlight>


Find all files or folders with the extension ".txt":
Find all files or folders with the extension ".txt":
: <syntaxhighlight lang=bash>find -name *.txt</syntaxhighlight>
: <syntaxhighlight inline lang=bash>find -name *.txt</syntaxhighlight>


View, in realtime, all additions to any file whose extension is ".log":
View, in realtime, all additions to any file whose extension is ".log":
: <syntaxhighlight lang=bash>find . -name "*.log" | xargs tail -f</syntaxhighlight>
: <syntaxhighlight inline lang=bash>find . -name "*.log" | xargs tail -f</syntaxhighlight>
(This is useful for monitoring web server (e.g. [[Apache web server|Apache]]) activity.)
(This is useful for monitoring web server (e.g. [[Apache web server|Apache]]) activity.)


Note that <code>-name</code> is case-sensitive; use <code>-iname</code> for case-agnostic.
Note that <code>-name</code> is case-sensitive; use <code>-iname</code> for case-agnostic.
==Links==
===Reference===
* {{l/manpage}}

Revision as of 13:43, 17 February 2025

<hide> page type::manual thing type::command platform::Linux </hide>

About

The Template:L/cmd command searches directory trees for files whose directory information meets particular criteria.

To search by content, use grep.

Examples

Find a file or folder named "kate" somewhere under the current folder:

find -name kate

Find all files or folders with the extension ".txt":

find -name *.txt

View, in realtime, all additions to any file whose extension is ".log":

find . -name "*.log" | xargs tail -f

(This is useful for monitoring web server (e.g. Apache) activity.)

Note that -name is case-sensitive; use -iname for case-agnostic.