Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two directories, directory1 and directory2. What is the cleanest way with a linux friendly script that would copy the latest files from directory1 onto directory2 including the same sub directory structures.

Actually, it doesn't have to be he latest, just copy all the files and put them into directory2. I cannot delete directory, it would have to take the files from 1 and put into directory 2.

It would be nice if these files were under source control but they aren't. I don't need to worry about deletes.

share|improve this question

1 Answer 1

Check rsync command.

rsync -ruv directory1 directory2

-r is to copy recursively from directory1 to directory2.

-u updates files. If file 'X' is in both directories, it will be copied if it's newer

-v verbose. Shows what is going on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.