I want to find all files in all subdirectories which has a name ExampleDir


+ ParentDirA
   + ChildDirA
     - file1.txt
   + ExampleDir
     - file2.txt
+ ParentDirB
   + ChildDirB
     - file3.csv
   + ExampleDir
     - file4.csv

Executing command should return: file2.txt and file4.csv

I have tried the following:

find . -type d -name "ExampleDir" | xargs find -type f
find . -type d -name "ExampleDir" -exec find -type f {} \;
find . -type d -name "ExampleDir" -exec find -type f {} +

They all return:

find: paths must precede expression

If I were to go down this route (which I think is logical) I would have to find out how to pipe the path to the find command.

Is there a better way?

2 Answers 2


Consider simplifying things with GNU find's -path extension:

find . -type f -path "*/ExampleDir/*"

I found my answer over at: Make xargs pass as first parameter

find . -type d -name "ExampleDir" | xargs -I {}  find {} -type f

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .