• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Common Unix Shell Commands: ... > Searching for Files, Directories, an...

Searching for Files, Directories, and More

Unix traditionally has provided useful tools for searching for files by name and content, and Apple has expanded on these by making available a command-line interface into the same databases that the Finder uses to locate files. Unix's traditional tools don't work from a database like the Finder's file searching function does, so they run more slowly. On the other hand, they aren't hampered by needing a database to run or by being only as current in their results as the last database update.

Finding Files: locate, find, mdfind

Sometimes you want to find some files, but you are not sure where they are. Three tools are available to search for files: locate, find and mdfind. Despite having the same purpose, these commands all behave a little bit differently. locate works from a database of file names that is updated periodically, and is aware of your user permissions and places that you'd typically look for files. It sometimes won't show you files that have been added recently, or that are in odd corners of the system, but it works quickly. find actually goes to look at everything on the system when you run it, so it can take a very, very long time to search, but it's always up to date, and always returns information on all files that you can see. mdfind uses Tiger's new Spotlight search facility, which also uses a database, but one that's supposed to be updated continuously for every change that is made to any file, and is capable of searching file contents as well as file names - unfortunately (as of April 2005) it's too easy to accidentally break Spotlight's indexing and have files that match, get lost.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint