Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


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.