.Dd June 10, 2004 .Dt mdfind 1 .Os Mac\ OS X .Sh NAME .Nm mdfind .Nd finds files matching a given query .Sh SYNOPSIS .Nm .Op Fl live .Op Fl count .Op Fl onlyin Ar directory .Op Fl name Ar fileName .Ar query .Sh DESCRIPTION The .Nm command consults the central metadata store and returns a list of files that match the given metadata query. The query can be a string or a query expression. .Pp The following options are available: .Bl -tag -width -d\ seconds .It Fl 0 Prints an .Tn ASCII NUL character after each result path. This is useful when used in conjunction with xargs -0. .It Fl live Causes the mdfind command to provide live-updates to the number of files matching the query. When an update causes the query results to change the number of matches is updated. The find can be cancelled by typing ctrl-C. .It Fl count Causes the mdfind command to output the total number of matches, instead of the path to the matching items. .It Fl onlyin Ar dir Limit the scope of the search to the directory specified. .It Fl name Ar fileName Searches for matching file names only. .It Fl literal Force the provided query string to be taken as a literal query string, without interpretation. .It Fl interpret Force the provided query string to be interpreted as if the user had typed the string into the Spotlight menu. For example, the string "search" would produce the following query string: .Dl (* = "search*"cdw || kMDItemTextContent = "search*"cdw) .El .Pp .Sh EXAMPLES .Pp The following examples are shown as given to the shell. .Pp This returns all files with any metadata attribute value matching the string "image": .Bd -literal -offset indent mdfind image .Ed .Pp This returns all files that contain "MyFavoriteAuthor" in the kMDItemAuthor metadata attribute: .Bd -literal -offset indent mdfind "kMDItemAuthors == '*MyFavoriteAuthor*'" .Ed .Pp This returns all files with any metadata attribute value matching the string "skateboard". The find continues to run after gathering the initial results, providing a count of the number of files that match the query. .Bd -literal -offset indent mdfind -live skateboard .Ed .Pp To get a list of the available attributes for use in constructing queries, see .Xr mdimport 1 , particularly the .Fl X switch. .Sh SEE ALSO .Xr mdimport 1 , .Xr mdls 1 , .Xr mdutil 1 , .Xr xargs 1