I have 2 folders , A and B. they are similar, but there are some files in A that are not present in B. what's the best way to copy only the new files in A into B, without changing the existing files in B?
Asked
Active
Viewed 4,300 times
2 Answers
4
You can use the --update option to rsync:
cd A
rsync -a --update . ../B/
And you can do something similar using tar's --skip-old-files option:
cd A
tar -cf- . | tar -C ../B -xv --skip-old-files -f-
larsks
- 44,886
- 15
- 124
- 183
1
cp with -n.
Ignacio Vazquez-Abrams
- 46,517
-
This is there on my Ubuntu system, but
man cpon my Centos 5.5 system seems to be missing it. – ehsanul Nov 19 '10 at 23:59
--ignore-existingif you don't want to replace the files that have the same names but different contents. – DerfK Nov 20 '10 at 04:26tarexample. – larsks Feb 24 '18 at 01:04