Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I do a search of all directories calles i18n under trees like src/main/resources using find or any other unix command.

Everything I'm trying doesn't work

I'm looking for something like:

$find . -name 'src/main/resources/i18n/ -type d
./foo/src/main/resources/i18n/
./bar/src/main/resources/i18n/
./xyz/src/main/resources/i18n/

But directory './foo/src/test/resources/i18n' should not appear.

share|improve this question
    
"everything I'm trying" is not very useful. What have you tried? –  user 99572 is fine Feb 18 '13 at 11:24
    
I've already found the correct option. –  Alfergon Feb 18 '13 at 11:41

2 Answers 2

up vote 1 down vote accepted

Found it at last:

find -type d -regex ".*src/main/resources/i18n"
share|improve this answer

You're almost there. Specify the common root dir of all your trees instead of .

find common/root/dir/ -type d -name i18n

(You can specify an absolute path there of course.)

share|improve this answer
    
This isn't working –  Alfergon Feb 18 '13 at 9:56
    
Could you be more specific about that? –  Karma Fusebox Feb 18 '13 at 9:57
    
$ find src/main/resources/ -type d -name i18n find: src/main/resources/: No such file or directory –  Alfergon Feb 18 '13 at 9:58
    
Ah, yes. I slightly misunderstood your question. See my edit, in your case the common root seems to be . but you need to use only "i18n" with -name, not the rest of the paths as well. –  Karma Fusebox Feb 18 '13 at 10:02
    
Yes, I also tried that, but that gives me both the 'src/main/resources/i18n' and the 'src/test/resources/i18n' that I don't need. –  Alfergon Feb 18 '13 at 10:09

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.