Search mac that contains a specific series of words in order with spaces between them



Hi,


I found spotlight, the searchbox in the upper right corner of finder windows, the + sign to add parameters, file types, yadda yadda yadda, this all is covered in about ten million threads on the internet.


What is NOT covered is how to find a specific series of words in order with spaces between them. When a string like that is searched, the result is every document matching any of the words, which can be tens of thousands of documents on my computer. What I need is the ONE or few documents that contain the exact phrase, including spaces. My experience with GREP at the command line is limited, but I have not figured out how to grep, spotlight, mdfind, or anything else to return a match to strings containing spaces.


If you could kindly pass along through this thread how that is done, I would be much obliged.


For kicks, the string I am looking for is "If you want a thing bad enough to go out and fight for it, to work day and night for it, to give up your time, your peace and your sleep for it"


Thank you

Mac Pro, 10.14

Posted on Feb 12, 2019 9:47 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 23, 2019 3:26 AM

If you use the Spotlight name operator, it will look for filenames that match a partial or full name string argument to it. Even extensions if you use name:.pdf. When you enter just a word or words punctuated by unquoted white-space, Spotlight sets off to find document content where any of those words are found, and then document names. Without any Spotlight operators, and just a double-quoted, white-space, punctuated string of words, Spotlight will start searching documents for the entire string. You can refine the results of the search by using other Spotlight operators, the Boolean operators (AND, OR, NOT), parenthetical grouping, and exclusion (kind:image -(.jpg).


Apple makes no guarantee that Spotlight will nicely order its results by any sort criteria other than the category entry order in Spotlight Preferences : Search Results.

Similar questions

6 replies
Question marked as Top-ranking reply

Mar 23, 2019 3:26 AM in response to danallenhouston

If you use the Spotlight name operator, it will look for filenames that match a partial or full name string argument to it. Even extensions if you use name:.pdf. When you enter just a word or words punctuated by unquoted white-space, Spotlight sets off to find document content where any of those words are found, and then document names. Without any Spotlight operators, and just a double-quoted, white-space, punctuated string of words, Spotlight will start searching documents for the entire string. You can refine the results of the search by using other Spotlight operators, the Boolean operators (AND, OR, NOT), parenthetical grouping, and exclusion (kind:image -(.jpg).


Apple makes no guarantee that Spotlight will nicely order its results by any sort criteria other than the category entry order in Spotlight Preferences : Search Results.

Mar 11, 2019 12:04 AM in response to John Galt

I don't know if I am missing something more direct in Narrow your search results on Mac. It looks like it is possible to find the documents containing the target phrase, but typing the target phrase into the search box with + signs between each word.


To test that, I created a document, put it into folder by itself.

Opened a finder window to view the folder with the test file in it.

Pasted the target phrase into the search box in finder. Nothing came back.

Hit cmd-spacebar to open search with spotlight.

Pasted the target phrase into spotlight. Nothing came back


Opened Terminal app, set the default directory to the one containing the test file, entered grep command:

 grep -rn   'peace' 


got the filename and line number back.


I am guessing for finder search or spotlight to find the file, I have to wait for indexing to run again.


Once the reindex is done (wait until tomorrow I guess), I'll see if the search and spotlight can find the word peace in that file. After that, I will take another run with tips at Narrow your search results on Mac



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Search mac that contains a specific series of words in order with spaces between them

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.