ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Hello,
I have to write a bash script to take XML files in directory x, copy them to directory y and then move the same set of files to directory z.
The script itself isn't a problem, except that there will be users uploading XML files into directory x constantly. So I need to in effect take a 'snapshot' of the files that are in there when the script is run.. copy them to y and then move them to z, ignoring any that are added between the time the cp is effected, and the mv.
I'm guessing that this involves doing a find, firing the result into a file, and then reading from that file, but this is something I've never done before.
Can someone advise? Oh, and no- this isn't a 'homework' exercise. It's for my work. Thanks.
That's what rsync does. Yes, it works on local files too:
Code:
rsync /path/ /topath1/
rsync /topath1/ /topath2/
Oops, sorry, I missed the move (=delete) part...
Ah, yes... rsync, I hadn't thought of that! That *would* work, but how do I stop the subsequent mv from treating files that weren't there when the rsync ran?
The first rsync works perfectly: I inserted a temporary `exit 0` in there, and checked $endDir0.
When it comes time to run the second rsync, I get..
Code:
rsync: mkstemp "/path_to_file/.1.xml.5yz6bY" failed: No such file or directory (2)
rsync: mkstemp "/path_to_file/.2.xml.Z8gDGe" failed: No such file or directory (2)
rsync: mkstemp "/path_to_file/3.xml.5Dnabv" failed: No such file or directory (2)
rsync: mkstemp "/path_to_file/.4.xml.62AHFL" failed: No such file or directory (2)
rsync: mkstemp "/path_to_file/.5.xml.vjXea2" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.