Deo Favente Posted December 23, 2007 Report Share Posted December 23, 2007 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 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. Quote Link to comment Share on other sites More sharing options...
Deo Favente Posted December 24, 2007 Author Report Share Posted December 24, 2007 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 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.