LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to cp filestructure for specific file pattern (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-cp-filestructure-for-specific-file-pattern-61561/)

mizuki 05-24-2003 12:18 PM

how to cp filestructure for specific file pattern
 
hi,
think that's a simple one:

how can i copy a a filestructure recursively for files matching a specific pattern like *.java -> copy all javafiles from that dir + subdirs and create the same dirstructure at the destination...d'you know what i mean?

thanx mizuki

david_ross 05-24-2003 02:00 PM

I don't know of a way to do it without writing a script but you could copy the folder then remove everything else.

mizuki 05-24-2003 02:06 PM

hmm
 
if i would copy the whole structure i would overwrite also files that are not *.java. that's what i want to avoid. i want to copy only the java files recursively from one structure to another. both file structures looking the same. i just want to "update" the java files in that structure. any idea?

david_ross 05-24-2003 02:09 PM

Ok folder1 has the .java files you want and folder3 is where you want the files to end up.
1) copy folder1 to folder2
2) remove all non .java files
3) move folder2s contents to folder3

acid_kewpie 05-24-2003 02:40 PM

find . -name *java | cpio -pvd /destination/directory

you could probably rearrange the command to allow you to copy from somewhere else than the current directory, but that will then use absolute paths, and so create leading directories all the way back to /, not just the current directory:
Code:

chris@trevor mail $ find .
.
./sent-mail
./saved-messages
./sent-mail-apr-2003
chris@trevor mail $ find /home/chris/mail/
/home/chris/mail/
/home/chris/mail/sent-mail
/home/chris/mail/saved-messages
/home/chris/mail/sent-mail-apr-2003


mizuki 05-24-2003 02:58 PM

thanx
 
sounds good...
i think that will work.
thank you.


All times are GMT -5. The time now is 05:38 AM.