The mdfind 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.

# Find a file by it's name:
mdfind -name file

# Find a file by it's content:
mdfind query

# Find a file containing a string, in a given directory:
mdfind -onlyin directory query

# To return all files with any metadata attribute value matching the string "image":
mdfind image

# To return all files that contain "MyFavoriteAuthor" in the kMDItemAuthor metadata attribute:
mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"

# 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.
mdfind -live skateboard

# To get a list of the available attributes for use in constructing queries, see
# mdimport(1), particularly the -X switch.