[SOLVED] recursively copy specific files using a list
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need to copy a set of specific files that exist in a directory structure with sub-directories. my initial attempt was to use
Code:
find . -name "*.h5" -exec cp {} ~/home/tmp ";"
this copied all of files that are of type .h5 but some of these .h5 files are really really big BIG, on the order of several gigs, and i don't need/want them.
so i need to find a way to copy specific files that all end in .h5 but also have different names such as:
where in this directory structure i only want to keep those files with a "color" as part their name. so i would first make a separate file that has a listing of the files i need:
Since you've started with find you can continue with that just as well as with other options. Options in find are connected by a logical AND unless specified otherwise. If you use a logical OR then you'll need to group parts using parenthesis. And to keep the shell from interpreting the parenthesis, they need to be escaped or quoted:
Second, that first option does seem unlikely, you may have a database of files which you wish to retain and then reference. Therefore my way of thinking would be that you would be creating a custom new file or set of files and perhaps taking that off system? Thus it might be going to a temporarily mounted file system like a thumb stick? Otherwise if you just need the reference names as part of your find command, then you could output just the list of found files and their locations and keep that versus copy the files all the time. All depends how much, how often, and how large the sub-selected files happen to be.
Second, that first option does seem unlikely, you may have a database of files which you wish to retain and then reference. Therefore my way of thinking would be that you would be creating a custom new file or set of files and perhaps taking that off system? Thus it might be going to a temporarily mounted file system like a thumb stick? Otherwise if you just need the reference names as part of your find command, then you could output just the list of found files and their locations and keep that versus copy the files all the time. All depends how much, how often, and how large the sub-selected files happen to be.
thanks for the thought!
but i can not do a mv as there are other users that also need access to the files
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.