next up previous contents index
Next: Expressions Up: findthe file searcher Previous: findthe file searcher

Generalities

Among the various commands seen so far, there were some which let the user recursively go down the directory tree in order to perform some action: the canonical examples are ls -R and rm -R. Good. find is the recursive command. Whenever you are thinking ``Well, I have to do so-and-so on all those kind of files in my own partition'', you have better think about using find. In a certain sense the fact that find finds files is just a side effect: its real occupation is to evaluate.

The basic structure of the command is as follows:

find path [...] expression [...] This at least on the GNU version; other version do not allow to specify more than one path, and besides it is very uncommon the need to do such a thing. The rough explanation of the command syntax is rather simple: you say from where you want to start the search (the path part; with GNU find you can omit this and it will be taken as default the current directory .), and which kind of search you want to perform (the expression part).

The standard behavior of the command is a little tricky, so it's worth to note it. Let's suppose that in your home directory there is a directory called garbage, containing a file foobar. You happily type find .\ -name foobar (which as you can guess searches for files named foobar), and you obtain ...nothing else than the prompt again. The trouble lies in the fact that find is by default a silent command; it just returns 0 if the search was completed (with or without finding anything) or a non-zero value if there had been some problem. This does not happen with the version you can find on Linux, but it is useful to remember it anyway.


next up previous contents index
Next: Expressions Up: findthe file searcher Previous: findthe file searcher

Converted on:
Mon Apr 1 08:59:56 EST 1996