Help - Search - Members - Calendar
Full Version: cp question [solved]
MandrivaUsers.org > General Help > Tips and Tricks
Deo Favente
Hi,
i have a question on how to use the cp command. I already comepleted the job, but i would like to know how i could use cp to shorten what i did so i could learn how to use it next time.
So for work i needed to copy a bunch of files. This is what my directory tree looks like:

there are 48 directories in level 1. The directories below don't always exsist in all 48 direcetories, but i want the directories abc, def, and ghi and their contents copied over to /usr/somedirectories/lib/
so that there will be lib/abc, lib/def, and lib/ghi. All files have different names (or should- there might be one or two human errors i can take care of manually, never know) so i want everything to merge, and there are plenty of duplicate folders and some folders might be empty.
My current idea is
CODE
cp */*/{abc,def,ghi,jkl,mno} /usr/somedirectories/lib/
does this work? what's wrong with it? I've already copmpleted the job so i cant try it on anything.
Deo Favente
Well what do you know. I tottally forgot i do have another chance to try it! But this time i have 4 levels between the top and the abc, def, ghi folders. So i tried my idea and it didnt work. It printed out "cp: omitting directory " then it listed all the directories that matched, and at the end it printed out "cp: cannot stat */*/*/*/jkl" cause it didnt match any folders. I also learned that all the second level folders were named the same thing cool. So then i tried
CODE
cp -R */xyz/*/*/{abc,def,ghi,jkl,mno} usr/somedirectories/lib/

and that worked yay! I hope i remember to prepend [solved] to the topic title.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.