copy certain files from subdirectories

Hi all,
I'd very grateful for some help with the following.

I have a variable number of subdirectories each of which contain a uniquely names results file of the form Results*.dat.

I would like to search through all subdirectories and copy out these results file to another directory so that I can combine them, diff them etc.

find . -name Results*.dat

will find all the files for me. How should I pass this to cp (copy)?

Thanks,
E

find . -name Results*.dat -exec cp {} /destination/dir \;

Read the man page for -exec

vino

1 Like

Thanks very much

find dir/ -name 'Results*.dat' | xargs cp -a --target-directory=/dest/dir --parents