find is one of the standard
unix/
linux utilities. On my system it lives in
/usr/bin (
heh, do a locate find or which find to find your find :).
I rarely use it actually, because locate and which have very simple syntax. On the other hand, find is way more powerful (and therefore the syntax is more
complex).
Among other godly things, find can execute a particular command on
every item that you find. For example - I wanted to clear all the
temporary swap files made by
gvim today. I briefly considered doing it manualy (as I have done before). But I've decided a few minutes (more like an hour) crawling through the
docs would be better. As I mentioned, find can execute a command on all the matches. By default it is
-print. That is,
find . -iname "*.pl" will be the same as
find . -iname "*.pl" -print. Of course any command can be placed in place of -print. To use my example from above, if I wanted to remove all .*.swo and .*.swp vim swap files I would do the following:
find . -iname ".*.sw?" -exec rm -i '{}' \; . To explain briefly:
{} is going to be replaced with a file match.
; signifies the end of the command. Use the
slashes to escape what the shell might consider special characters.
Note: Never ever run commands that you don't understand, or have doubts about (
duh). In particular in
mylo's writeup above, find will pipe every file on your harddrive to
rm. I bet you know what that means.