Find and copy these files to particular directory

RedHat Enterprise Linux 5.4

I have some files with the extension

.cdp

in several directories in various mountpoints(filesystems) . I would like to find and copy all these files into a single directory

/u03/diagnore/data

.

How can I do this ?

Try

find /source_path/ -name '*.cdp' -exec cp {} /Destination_path/ \;
1 Like

Thank you Pamu. What is the significance of curly braces
{}in this command and why is it placed between cp and the target directory ?

find ... | pax -rw destination

If filename collisions are possible, with pax you can use -k to always keep the existing file, or -u to update (overwrite when the existing destination file is older).

If you need a fancier way to deal with collisions, then you need to provide more info.

Regards,
Alister

---------- Post updated at 10:05 AM ---------- Previous update was at 10:04 AM ----------

Type man find at your prompt and read the section which discusses -exec .

Regards,
Alister

1 Like