mdfind 是 Spotlight 的命令列介面,能在終端機以極快速度搜尋檔案、中繼資料、內容,適合腳本自動化或鍵盤流操作。

# 依檔名搜尋 (不區分大小寫)
mdfind -name homebrew
# 依內容搜尋關鍵字
mdfind "專案計畫書"
# 限定資料夾搜尋
mdfind -onlyin ~/Documents "會議紀錄"
# 顯示即時更新計數 (適合腳本監控)
mdfind -live "幫助文件"
man mdfind
mdfind 直接讀取 Spotlight 索引,速度遠快於 find 遍歷檔案系統。善用它能在終端機瞬間定位任何檔案。