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?

  • 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

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!
| improve this answer | |

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 \)


  • -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.

| 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

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.

| improve this answer | |
  • 4
    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

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.

| improve this answer | |
  • Does not work on APFS-formatted drives. – Victor Engel Sep 22 '18 at 16:12

ag can search hidden files by file name.

For instance:

ag --hidden -g ".swiftlint.yml" ~/

How to install

brew install the_silver_searcher


rg is faster than ag.

rg --files --hidden ~/ |rg  ".swiftlint.yml"

How to install

brew install ripgrep


| improve this answer | |
  • How does this help in the situation described by the OP (who apparently doesn't know the name of the hidden files)? – nohillside May 19 at 7:47
  • It works as well. For instance, rg --files --hidden ~/ |rg ".swiftlint*" – UnchartedWorks May 19 at 7:57

If you want to search .DS_Store hidden files, this command works well.

du -a | grep .DS_Store
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .