mdfindコマンド

提供: MonoBook
ナビゲーションに移動 検索に移動

mdfindコマンドとは、Mac OS Xに搭載されているコマンドのひとつで、コマンドラインSpotlight全文検索を利用できるというものである。

概要[編集 | ソースを編集]

mdfindコマンドはunixOSでは定番のgrepコマンドfindコマンドに似ているが、指定ディレクトリ以下の全データを力任せに検索するのではなく、あらかじめ作られた索引に対しての全文検索であるという点が異なる。

利用には索引が必須であるためSpotlightに嫌悪感を抱き無効化している人は利用できない。

主な使い方[編集 | ソースを編集]

単語検索

$ mdfind "検索語句"

ファイル名で検索

$ mdfind -name "ファイル名の一部"

ディレクトリ指定で検索

$ mdfind -onlyin ~/Documents "検索語句"

Usage[編集 | ソースを編集]

Yosemiteでの「mdfind --help」したときに出力されるusage。

Usage: mdfind [-live] [-count] [-onlyin directory] [-name fileName | -s smartFolderName | query]
list the files matching the query
query can be an expression or a sequence of words

	-attr <attr>      Fetches the value of the specified attribute
	-count            Query only reports matching items count
	-onlyin <dir>     Search only within given directory
	-live             Query should stay active
	-name <name>      Search on file name only
	-reprint          Reprint results on live update
	-s <name>         Show contents of smart folder <name>
	-0                Use NUL (``\0'') as a path separator, for use with xargs -0.

example:  mdfind image
example:  mdfind -onlyin ~ image
example:  mdfind -name stdlib.h
example:  mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"
example:  mdfind -live MyFavoriteAuthor

関連項目[編集 | ソースを編集]

参考文献[編集 | ソースを編集]