-1

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.

2
  • "everything I'm trying" is not very useful. What have you tried? Commented Feb 18, 2013 at 11:24
  • I've already found the correct option. Commented Feb 18, 2013 at 11:41

2 Answers 2

1

Found it at last:

find -type d -regex ".*src/main/resources/i18n" 
0

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

7
  • This isn't working Commented Feb 18, 2013 at 9:56
  • Could you be more specific about that? Commented Feb 18, 2013 at 9:57
  • $ find src/main/resources/ -type d -name i18n find: src/main/resources/: No such file or directory Commented Feb 18, 2013 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. Commented Feb 18, 2013 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. Commented Feb 18, 2013 at 10:09

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.