Mac OS X: The BSD "find" Command

The BSD "find" Command Searches UFS, HFS, and HFS Extended Volumes.
This article has been archived and is no longer updated by Apple.
Note: This information is valid for all versions of Mac OS X and Mac OS X Server.

The BSD "find" command implemented in Mac OS X Server will search Macintosh HFS and Macintosh HFS Extended volumes. Because volumes with these format types are auto-mounted in the root file system, searching the root volume "/" will locate files on any mounted local volume.

Thus, to locate a file typically found on an HFS Extended volume on a server that has netboot clients, enter:
    find / -name "Mac NC #" -print &

This should return all occurrences of files or directories on "/" whose names include the string specified in quotes, and print it to standard io (the screen). The ampersand "&" specifies to do this in the background.

Note: In this example, the search string is in quotes; these quotes are necessary because of the space characters included in the string. Searching for a name that is all one word with no illegal characters, such as "hostconfig", does not require quotes. As in traditional BSD unix, the backslash character, "\\", may be used before an illegal character to cause it to be parsed as part of the search string:
    find / -name Mac\\ NC\\ # -print &

You can also use the "locate" command, which is easy to use and faster than find. Simply type "locate" followed by the name or part of a name of files you are looking for and press Return. You should get a list displaying the paths to those files. The locate command searches a database of files on the drive, which can get out of date. If you are searching for a file that you know exists but is not found, you can run the 'weekly' script manually to update this database. To do so type the following command:
    sudo sh /etc/weekly

Press Return, enter your password, and the weekly script will run and update your locate database.

Execute "man find" or "man locate" at the command line to get more information on using these commands.
Published Date: Feb 20, 2012