What options do I need to use with find to exclude hidden files?

link|improve this question

3  
Aside: the reason there isn't some special support for this task is that the only thing special about files named with a leading '.' is that there are not listed by ls unless specifically requested: they are completely ordinary files in every respect, its just that ls lets you ignore them by default. – dmckee Jun 16 '10 at 0:32
1  
Question: do you want to hide something like .hidden/visible.txt? – Keith Thompson Oct 13 '11 at 0:20
feedback

3 Answers

up vote 5 down vote accepted

I found this here:

find . \( ! -regex '.*/\..*' \) -type f -name "whatever"
link|improve this answer
Why not just \( ! -name '.*' \)? – grawity Jun 16 '10 at 15:15
@grawity I just found that, I don't know entirely how it works. Would yours not only hide hidden files, but hidden directories and all their sub-content and hidden files in subfolders? – Dan Jun 16 '10 at 16:05
No, it wouldn't :/ But \( ! -path '*/.*' \) would. – grawity Jun 16 '10 at 16:38
@grawity Ya, I guess I made an assumption about what the OP wanted... Your -name solution is probably the closest to what they were asking for. – Dan Jun 16 '10 at 18:07
@grawity&Dan: Isn't it ( !-path '^.*' ) ?? your solutions will ignore any file that has a '.' anywhere in the file name like a.exe, b.out etc.... – Anand Jeyahar Jun 30 '11 at 8:27
feedback

This doesn't answer your question, but for the task of finding non-hidden files I like to let find find all the files then filter with grep.

find . -type f | grep -v '/\.'

Similar to your approach but perhaps a bit simpler.

link|improve this answer
feedback

You can look at the -prune option

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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