Program to search for text within files?

Discussion in 'Mac Basics and Help' started by -mattias-, Sep 26, 2012.

  1. -mattias- macrumors member

    Dec 11, 2009
    I'm looking for a document on my Mac, but I don't know where it is and I cannot remeber the name or anything, only some of the text inside.

    So I'm looking for a program, that can search for a phrase or something of text inside documents through all my documents on my harddisk.
  2. lshaner macrumors regular


    Mar 7, 2007
    Are you saying that the Mac's built-in Spotlight feature doesn't find the doc?

    You could open a terminal and use a combination of find and grep to get potential matches.

    $ find ~ -type f -exec grep -i 'your exact phrase' /dev/null {} \;

    The /dev/null part is just a trick to get the filenames to always print, even though each grep is really against a single file. Or if you used grep -l (ell) then it would show only the filenames with matches and you could leave the /dev/null off.

    Sorry, it won't likely find matches in documents stored in compressed or binary form. You might find a few more hits with 'strings' instead of grep, but then it won't be case insensitive like grep -i.
  3. old-wiz macrumors G3

    Mar 26, 2008
    West Suburban Boston Ma
    Ah..the good old days of *NIX commands.
  4. Tumbleweed666 macrumors 68000


    Mar 20, 2009
    Near London, UK.
    Have you tried Spotlight? If not, CMD SPACE then type the word you know is in the doc
  5. mankar4 macrumors 6502a


    Aug 23, 2007
  6. GGJstudios macrumors Westmere


    May 16, 2008
    In Finder, you can search for your search terms in file names or in file contents. No other app is required.

Share This Page