I'm trying to use the Linux find command to find all directories and sub-directories that do not have .svn (Subversion hidden folders) in their path. I can only get it to exclude the actual .svn directories themselves, but not any of the sub-directories.

Here is what I'm doing right now:

find . -type d \! -iname '*.svn*'

I've also tried:

find . -type d \! iname '.svn' \! iname '.svn/*'

Just an FYI, I'm trying to use the find pattern so I can apply some subversion properties to all directories in my repository excluding the subversion hidden folders and their sub-directories (by applying the exec command to the directories returned from the find command)..

TIA

link|improve this question
feedback

5 Answers

up vote 13 down vote accepted
find . -type d -not \( -name .svn -prune \)
link|improve this answer
I'll go with this one, though they all seemed to work. – Jason Down Jun 29 '09 at 15:44
I've used -prune on find before, but I hadn't seen that \( ... \) trick. Thanks. – Rory Jun 29 '09 at 16:40
Works like a charm :) Thanks! – Piskvor Feb 8 '10 at 16:03
feedback

What about simply

find . -type d |  grep -v '.svn'
link|improve this answer
Loses your ability to use any of the find actions. – David Pashley Jun 29 '09 at 15:45
Yes, but what about a nice little sh loop instead? :) for FILE in find . -type d | grep -v '.svn'; do echo whatever; done – wazoox Jun 29 '09 at 19:22
feedback

What about the -path option to find?

find . -type d ! -path '*.svn*'
link|improve this answer
1  
Missed off a closing quote. There's an outside chance that the wildcards might be too greedy. – Dan Carley Jun 29 '09 at 15:37
feedback

find . -path './tmp' -prune -o .......

link|improve this answer
feedback

You could use:

find . -type d -not -wholename '*.svn*' 
link|improve this answer
it stripped the * from the front of the answer... should be find . -type d -not -wholename '/.svn/' (that's wholename squote asterisk slash dot svn slash asterisk squote) – TechFriend Jul 29 '10 at 18:38
feedback

Your Answer

 
or
required, but never shown

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