Copying Nested Directories With Ditto
You can copy nested directories with cp
using the -R
(recursive) flag. The way cp
works is that it replaces the target location with the source directory, wiping out whatever files or directories reside at the target location.
Conversely, the ditto
utility, available on OS X's version of Unix, does recursive directory copies by default and merges the contents of any existing directories.
As an example, here are two folders, folder1
and folder2
:
Using ditto
to copy folder1
to folder2
we get a folder2
where directories from folder1
are created and existing directories are merged together.
See man ditto
for more details.
Last updated