Need to find a string of text on my mac

It's either a .doc, docx, or txt file.

The text string is "burrito bandage"

I've tried a previous suggestion I found in support, but see attached. Is it searching? Did Something go wrong and I'm an idiot with terminal anyway. How can I find it? If suggestion is use terminal please spell it out. Please?

iMac Pro

Posted on Feb 28, 2019 12:47 PM

Reply

Similar questions

2 replies

Feb 28, 2019 2:15 PM in response to nowsthetime

A Spotlight search can find a string of words, whether from a Finder window search field, or the Spotlight panel itself:


(kind:word OR kind:text) AND "burrito bandage"


Your use of grep was incorrect, and the wrong tool for looking inside Word .doc and .docx documents. Word .doc are binary documents and you need to get that content into text so grep can scan it. Word .docx are zip/compressed documents and grep cannot see within them.


The following will search your entire home directory for Word .doc files containing the string "burrito bandage" and will print the filename where the string was found, a tab, and the string match count in the given file — if greater than 0.


sudo find ~ -iname "*.doc" -print0 -exec sh -c 'textutil -convert txt -stdout {} | egrep -c "burrito bandage"' \; | xargs -n 2 -0 -P 2 -I{} printf '%s\t%s' {} | grep -v '0'


and the following will drill down into your entire home directory looking for the string "burrito bandage" in every .docx document it encounters where there is a match on that string:


sudo find ~ -iname "*.docx" -type f -print0 -exec sh -c 'unzip -p {} "word/document.xml" | egrep -ic "burrito bandage"' \; | xargs -n 2 -0 -P 2 -I{} printf '%s\t%s' {} | grep -v '0'


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.

Need to find a string of text on my mac

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