Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wanting to search recursively through a directory and find all files that are not hidden files themselves and are not in a hidden dir. I tried using find . -type f -not -name '.*' which excludes any base name hidden files, but it still recurses into hidden directories.


I would want the output to be:


however, I get:


EDIT: I would like to list only files, i.e., -type f

share|improve this question
up vote 8 down vote accepted

You'll have to "prune" the directories you don't want to recurse into:

find dir -name '.*' -prune -o -print

Usually -prune is used with -o because it returns true, so when combined with short-circuit OR, it has the effect of skipping the -print on hidden files / directories, which is exactly what you want.

share|improve this answer
Is there anyway to only display the results of type file with this method? I forgot to mention that and adding -type f seems to break this. – user1227038 Jan 17 '13 at 4:58
Where are you adding -type f? I'd put it between -o and -print. – jw013 Jan 17 '13 at 5:14
Thanks @jw013 , that was just about the only place I didn't try. – user1227038 Jan 17 '13 at 5:30
On more complex expressions you'll need to use parenteses for grouping... – vonbrand Jan 21 '13 at 19:31

Your Answer


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.