Copying files from accept list with parents

Sometimes you have a directory structure that looks like this: test ├── rep1 │   ├── test.csv │   └── test.graphql ├── rep2 │   └── test.graphql └── rep3 └── test.csv And you want to copy every *.graphql files somewhere and keep the structure in a new directory: test ├── rep1 │   └── test.graphql ├── rep2    └── test.graphql Too easy with tar: mkdir new_directory find graph/ -name \*.graphql | xargs tar cv -- | tar xvf - -C new_directory