News for hackers. Stuff that matters.
Re:Find is a beautiful tool by scottw on Monday July 25, 2011 @09:51AM (#2802586)
I wrote an article on `find` performance a few years ago, may be useful to someone:

http://scott.wiersdorf.org/blarney/071024a.html

tl;dr version:

find examines each entry in a directory hierarchy; if the entry (be it a regular file, symlink, directory, device, or whatever) matches the given criteria, it will be printed. If no criteria are given, it’s an automatic match (and will be printed).

find evaluates its expressions in the order you specify them; by carefully choosing the order of the expressions, you can shave tons of time off the cost of the search and get your wanted results quicker.

As is true with most programming endeavours, a little investment up front in crafting the expressions will yield better results later. If you’re only running a find operation once, maybe you don’t want to take too much time fussing over saving a few syscalls, but if you will be running find frequently (e.g., as part of a cron, or some other regular occurance), do your disk a favor and let find skip as much as possible.

There are no comments on this comment yet.