How would it be possible to copy all new contents from one directory to another so that only new files are copied from the source directory (both directories have the same naming tree). For example, here is the layout of directory A:
/dirA
a.php
b.txt
subdirA1/
readme.txt
config
source_file1.c
/dirB
c.php
subdirA1/
readme.txt
at the end dirB should have all the new files in dirA. Assume that there are only new files in dirA and its sub directories. The result should be the union of the two directories:
/dirB
a.php
b.txt
c.php
subdirA1/
readme.txt
config
source_file1.c
I have tried using cp -ra:
cp -ra dirA/* dirB/
but dirB is completely overwritten by dirA.
rsync -a dirA/ dirB/
overwrites the files indirB
with files by the same name fromdirA
, just likecp -a
. What you're looking for isrsync -a --ignore-existing
.