Chapter 2. Searching and Metadata

If a Unix geek needs to find something on her system, she’ll probably use locate or find, depending on what she’s looking for. Because locate is based on a static database that’s regenerated only periodically (see Periodic Jobs” in Chapter 4), it would be the best choice for things that don’t change a lot (e.g., virtually anything in /usr). It’s also much faster because it has that database to consult. Trusty old find, slow as molasses, is what you want when you need more control over the search or when you’re looking for something that locate doesn’t know about, such as files that have been created recently.

Beginning with Tiger, though, Mac OS X has offered another search capability: Spotlight, which stores file metadata and sifts through it faster than a herd of sheep can clear a field. Spotlight comes in two forms: a GUI interface accessible from the menu bar, and a suite of command-line utilities. This chapter introduces you to Spotlight and shows you how to take advantage of all it has to offer.

Spotlight

Remember the relentless disk grinding you heard after you first installed the operating system? That was Spotlight creating its initial database. Spotlight is a repository of metadata for certain types of files. It gathers information about any file (or data record, such as an iCal event or video file) for which it has an importer (an operating system plug-in that extracts metadata from a file). To see all the importers on your system, look ...

Get Mac OS X For Unix Geeks, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.