1

I have two directories with similar files, (one being a backup), what is a command that allows me to copy over only the files that are different to the backup?

cp -rf firstDir/* secondDir is awfully inefficient, since a lot of the files are the same.

2 Answers 2

7

Rsync is the best way

rsync -va ~/from/ ~/to 

note the trailing / on 'from' is important!
v is verbose mode - leave it on until it's working, a is archive = copy all the file info.

Or you can just use the -u (update) flag to cp = only copy newer files.

Sign up to request clarification or add additional context in comments.

Comments

2

rsync

will keep the directories the same efficiently. Will work of ssh as well..

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.