Spotlight

Spotlight is a fast, as-you-type system-wide search found in macOS. It was one of the biggest new features introduced in Mac OS X 10.4 (Tiger). It can entirely change how the user interacts with files, websites and applications on the Mac. It is a significant alternative to the window file-organization system of the 1980s.

Indexing
Spotlight builds a database of metadata keywords in documents on the user's hard drive. This initially takes place right after a successful installation of Mac OS X 10.4 or later. Updates are made to this file continuously in the background with every file change on the drive.

Usage
Using a metadata search engine, Spotlight can find almost anything on a Mac, including documents, pictures, music, websites, searches, definitions, applications, System Preferences panes, as well as specific words in documents and PDFs. Searches can also be modified with date created, date modified, size, type and many more attributes.

Spotlight works with major input languages, including Western characters and East Asian ideograms.

Invoking Spotlight
The easiest way to invoke Spotlight is to use the Spotlight menu on the top-right hand corner of the Mac. Other ways to invoke it include using search fields, or with the key combination  .

Integration with applications
Spotlight can be — and is — integrated into third-party applications in Mac OS X 10.4.

Spotlight settings
Spotlight can be configured in the Spotlight preference pane of System Preferences. However, some things can't be configured. For example, Spotlight ignores files without extensions and ignores "." files even when Finder has been told not to.

Spotlight command line use
In Terminal, "mdfind stuff" is a simple way to find files containing 'stuff'. But mdfind can do much more: mdfind 'kMDItemTextContent == "*Seneca*" && kMDItemContentType != "com.apple.mail.emlx"'

Use "mdls filesname" to see all the things Spotlight knows about a file.Simple shell scripts:

mdfind "kMDItemTextContent == '*$1*'"
 * "mygrep"

mdfind "kMDItemFSName == '$1'"
 * "myfind"