Operating System - HP-UX
1833778 Members
2278 Online
110063 Solutions
New Discussion

Re: How to copy files from different subdirs to destination path

 
yogesh kumar_2
Frequent Advisor

How to copy files from different subdirs to destination path

Hi

I have common directory /se.Inside /se directory different sub directories are there like file1,file2.Inside file and file2 different subdirectories are there.At the end i have files like .cpp and some other file formats.My problem is that i want to copy the file .cpp and other file formats in to some other path.(my destination path).

I want to check file1 and file2 and backup .ccp file format files in to destination path.
7 REPLIES 7
Sandeep_Chaudhary
Trusted Contributor

Re: How to copy files from different subdirs to destination path

cp -R /se/file1/*.cpp /se/file2/*.cpp /destinationpath
yogesh kumar_2
Frequent Advisor

Re: How to copy files from different subdirs to destination path

Hi

I have different file formats like .cpp,.isd.I want to copy only modified files like the letter starts with M(capital M)
Sandeep_Chaudhary
Trusted Contributor

Re: How to copy files from different subdirs to destination path

sorry !!!!!

find /se/file1 -name "*.cpp" |xargs -i cp {} /destination

find /se/file2 -name "*.cpp" |xargs -i cp {} /destination
Try this.

sorry fr my previous reply and not reading question properly
Sandeep_Chaudhary
Trusted Contributor

Re: How to copy files from different subdirs to destination path

find /se/file1 -name "M*.cpp" |xargs -i cp {} /destination
find /se/file1 -name "M*.cpp" |xargs -i cp {} /destination

is this what u r expecting
SKR_1
Trusted Contributor

Re: How to copy files from different subdirs to destination path

Please explain properly.

Sometimes you r asking to copy .cpp and other fromat file also. Sometimes you r saying to copy the files starting from capital M.

Thanks

SKR
Dennis Handly
Acclaimed Contributor

Re: How to copy files from different subdirs to destination path

>Sandeep: find /se/file1 -name "M*.cpp" |xargs -i cp {} /destination

You can combine the finds:
find /se/file1 /se/file2 \( -name "M*.cpp" -o -name "other-formats" -o ... \) ...

Instead of xargs, you might be able to do:
-exec cp {} /destination +
yogesh kumar_2
Frequent Advisor

Re: How to copy files from different subdirs to destination path

I found the solution