1

Let's say I want to find all the node_modules folders in my Code directory:

find ~/Code -name 'node_modules' -type d

But what if I want to find all the setup folders, that themselves are inside test folders?

# nope
find ~/Code -name 'test/setup' -type d

# nope
find ~/Code -path 'test' -name 'setup' -type d

How do I perform a find search that matches multiple path components like this? i.e. find something named foo/bar/baz.widget, nested arbitrarily deep?

  • It seems that -path matches the whole path, try '*test/setup'. – Paulo Dec 14 '18 at 1:27
2

Sounds like you need to use a wildcard there:

$ find ~/Code -path '*/test/setup' -type d

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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