Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use the find command in linux to find a specific file nested within a specific directory structure, say dir1/dir2/reqdfile.

But this directory structure can itself be nested within any parent directory structure.

Is it possible to a search like?

find directory_to_search -name "**/dir1/dir2/reqdfile"

What is the exact syntax?

share|improve this question
up vote 8 down vote accepted

Use -path instead of -name:

find directory_to_search -path "*/dir1/dir2/reqdfile"

Note that there's only one asterisk.

share|improve this answer

In general, a quick and dirty alternative would be to use grep. Though it's not as clean for find specifically, thanks to the -path option, many similar cases can be solved like so:

find directory | grep "/dir1/dir2/reqdfile$"
share|improve this answer

Your Answer


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.