Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

How to find stuff on your Mac hard drives


Here are my notes on finding (and replacing) stuff on a Mac.

Using Command line

  1. cd to the path

  2. To find text “Exception” within files of “.md” type at the current folders down:

    find . –name "*.md" –print | xargs grep "Exception"

    Protected folders and files are not processed:

    find: ./.DocumentRevisions-V100: Permission denied
    find: ./.fseventsd: Permission denied
    find: ./.MobileBackups: Permission denied
    find: ./.Spotlight-V100: Permission denied
    find: ./.Trashes: Permission denied
    find: ./dev/fd/3: Not a directory
    find: ./dev/fd/4: Not a directory
    find: fts_read: Permission denied

Find “foo” within files by diving recursively into folders :

   grep -ri "foo" .
  • Remove the i to not ignore case distinctions.

Display print only the filenames with GNU grep:

   grep -r -l "foo" .


Use -print0 option to find filenames that contain spaces or other metacharacters:

   find /path/to/dir -type f -print0 | xargs -0 grep -l "foo"

Find file names

Find files using file-name ( case in-sensitve find)

   find -iname "MyCProgram.c"

Execute commands on files found by the find command

   find -iname "MyCProgram.c" -exec md5sum {} \;

Find all empty files in home directory

   find ~ -empty

More find examples: http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/ Mommy, I found it! — 15 Practical Linux Find Command Examples



Hidden files

If you are searching for hidden files:

How to Search the Content of Your Files on Windows

Using Utility programs


Using IDE

If you’re working in an IDE, it’s simpler