Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I need to find some configs buried in some hidden folders and can't recall where they are to navigate to them directly Cmd+Shift+G.

I did a sudo find -name Foo* (slow), but none of the returned files were in hidden folders.

What is the easiest way to search all hidden files?

share|improve this question
    
Note: Using sudo is unnecessary unless you need to search in directories that you do not have access to. Searching in hidden directories does not require elevated privileges, if that's why it's being used in your example. –  Chris Page Jul 4 '12 at 23:06

4 Answers 4

up vote 10 down vote accepted

mdfind seems to ignore a lot of hidden files. mdfind 'kMDItemFSInvisible==1&&kMDItemFSName==filename' does list .DS_Store files, but not for example .bash_history. I haven't found any way to search for files in some hidden directories like /private/etc/.

Anyway, Find Any File is a lot faster than find.

Find Any File is a program for Mac OS X that lets you search for files on your disks.

  • Contrary to Spotlight, it does not use a database but instead uses the file system driver's fast search operations, where available. This lets you search for file properties such as name, dates, size, etc., but not for file content (use Spotlight or EasyFind for that).
  • Find Any File can find files that Spotlight doesn't, e.g. those inside bundles and packages and in inside folders that are usually excluded from Spotlight search.
  • Finally, it is quite fast. A search only takes a few seconds on an internal hard disk or SSD. Try for yourself!
share|improve this answer

Try the locate command. You will have to sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist first and wait for the locate DB to be generated.

share|improve this answer
3  
It's such a nuisance that Spotlight doesn't pick up hidden / (dot-)files, because mdfind is vastly superior to slocate. –  Jason Salaz Feb 20 '12 at 17:35

Assuming that by “hidden file” you mean files whose name begins with a dot or that are located somewhere under a directory whose name begins with a dot, and not other forms of invisible files, the following command prints the names of all hidden files. It's slow as it goes over all the file names everywhere on your system.

sudo find / -name '.*' \( -type d -exec find {} \; -prune -o -print \)

Explanation:

  • -type d -exec find {} \; -prune executes find on every directory (whose name matched .*), and skips descending into that directory because of the -prune.
  • -type d … -o -print causes all non-directories that match .* to be printed.

If you're looking for a file with a specific name or pattern:

sudo find / -name 'Foo*' -path '*/.*'

The */.* pattern on the whole path forces matches to be under a hidden directory.

You may want to add -xdev after the / to avoid traversing special filesystems and removable disks.

share|improve this answer
    
Ah, thanks. And it looks like -x is preferred now, as -xdev is deprecated. –  Old McStopher Feb 21 '12 at 17:33

EasyFind is an excellent alternative app to get the job done. It's free and easy. You can search for text in files (even invisible ones). <= This may be an easier way to find your config files.

You can get it from the App Store https://itunes.apple.com/us/app/easyfind/id411673888?mt=12

Disclaimer: I am not affiliated with the developer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.