| DITTO(1) | General Commands Manual | DITTO(1) |
ditto — copy
directory hierarchies, create and extract archives
ditto |
[-v] [-V]
[-X] [<options>] src ...
dst_directory |
ditto |
[-v] [-V]
[<options>] src_file dst_file |
ditto |
-c [-z |
-j | -k]
[-v] [-V]
[-X] [<options>] src
dst_archive |
ditto |
-x [-z |
-j | -k]
[-v] [-V]
[<options>] src_archive ... dst_directory |
ditto |
-h | --help |
In its first form, ditto copies one or
more source files or directories to a destination directory. If the
destination directory does not exist it will be created before the first
source is copied. If the destination directory already exists then the
source directories are merged with the previous contents of the
destination.
In its second form, ditto copies a file to
the supplied dst_file pathname.
The next two forms reflect ditto's ability
to create and extract archives. These archives can be either CPIO format
(preferred for unix content) or PKZip (for Windows compatibility).
src_archive (and dst_archive)
can be the single character '-', causing ditto to read (write) archive data
from stdin (or to stdout, respectively).
ditto follows symbolic links provided as
arguments but does not follow any links as it traverses the source or
destination hierarchies. ditto overwrites existing
files, symbolic links, and devices in the destination when these are copied
from a source. The resulting files, links, and devices will have the same
mode, access time, modification time, owner, and group as the source items
from which they are copied. Pipes, sockets, and files with names beginning
with .nfs or .afpDeleted will be ignored. ditto does
not modify the mode, owner, group, extended attributes, or ACLs of existing
directories in the destination. Files and symbolic links cannot overwrite
directories or vice-versa.
ditto can be used to "thin"
Universal Mach-O binaries during a copy. ditto can
also copy files selectively based on the contents of a BOM ("Bill of
Materials") file. ditto preserves file hard
links (but not directory hard links) present in the source directories and
preserves setuid and setgid modes when run as the superuser.
ditto will preserve resource forks and HFS
meta-data information when copying unless instructed otherwise using
--norsrc . --norsrc will
disable copy of resource forks, extended attributes, Access Control Lists
(ACLs), as well as quarantine bits. DITTONORSRC can
be set in the environment as an alias to --norsrc
--noextattr --noacl
--noqtn on the command line. However, each option
can be individually turned on or off, see the OPTIONS section for more
details.
-h,
--help-v-V-X-c-k is given. CPIO archives should be stored
in files with names ending in .cpio. Compressed CPIO archives should be
stored in files with names ending in .cpgz.-z-j-x-k is given. Compressed CPIO is
automatically handled.-k--keepParent--arch
arch--arch options are specified then the resulting
destination file will contain each of the specified architectures (if they
are present in the source file). arch should be
specified as "arm64", "x86_64", etc.--bom
bom--rsrcditto
will store this data in Carbon-compatible ._ AppleDouble files on
filesystems that do not natively support resource forks. As of Mac OS X
10.4, --rsrc is default behavior.--norsrc--norsrc and --rsrc are
passed, whichever is passed last will take precedence. Both options
override DITTONORSRC. Unless explicitly specified,
--norsrc also implies
--noextattr and --noacl to
match the behavior of Mac OS X 10.4.--extattr--rsrc). As
of Mac OS X 10.5, --extattr is the default.--noextattr--norsrc).--qtn--qtn is the default.--noqtn--acl--acl is the default.--noacl--nocache--hfsCompression--nohfsCompression--nohfsCompression is the
default.--preserveHFSCompression--preserveHFSCompression is the
default.--nopreserveHFSCompression--sequesterRsrc--zlibCompressionLevel
num--password--persistRootless--nopersistRootless--nonAtomicCopiesditto will atomically swap new files into place
when completing a copy.--segmentLargeFiles--keepBinariesditto will set aside the
original Mach-O binary when it is being replaced. The file name will be
changed to a random number preceeded by the prefix .BC.T_--keepBinariesList
pathditto keeps binary files it will record the
location of the kept file in the file at the specified path.--keepBinariesPattern
regex--lang
lang-b option the user can specify language variants
to filter from the index bom. By default ditto
will create a new index bom at /tmp/ditto.XXXXX representing the filtered
contents. The user can direct the output bom via the
-o flag.--outBom
bom-o flag or the
-l flags.--clone--noclone--option
key=valueThe command:
ditto src_directory
dst_directoryThe command:
ditto src_directory
dir/dst_directoryThe command:
ditto src-1 ... src-n
dst_directoryThe command:
ditto --arch ppc universal_file
thin_fileThe command:
ditto -c --norsrc Scripts -|ssh rhost
ditto -x --norsrc - ./ScriptsThe command:
pax -f archive.cpioThe command:
pax -zf archive.cpgzThe command:
ditto -c -k --sequesterRsrc
--keepParent src_directory archive.zipThe command:
unzip -l archive.zipditto returns 0 if everything is copied,
otherwise non-zero. ditto almost never gives up,
preferring to report errors along the way. Diagnostic messages will be
printed to standard error.
DITTOABORTDITTOABORT is set,
ditto will call abort(3) if it
encounters a fatal error.DITTONORSRCDITTONORSRC is set but
--rsrc, --extattr, and
--acl are not specified,
ditto will not preserve those additional types of
metadata.DITTOKEEPBINARIESPATTERNDITTOKEEPBINARIESPATTERN is set,
ditto will keep files that match the regular
expression. This matches the behavior of
--keepBinariesPatternDITTOKEEPBINARIESDIRditto will keep the original file
adjacent to its replacement. If the environment variable
DITTOKEEPBINARIESDIR is set,
ditto will move kept files into the specified
directory path. The files will be renamed to a random UUID and the
directory will be kept balanced.DITTO_TEST_OPTIONSDITTO_TEST_OPTIONS is set to 1
ditto will print the parameters to be passed to
BOMCopierCopyWithOptions for each source and destination pair, including
the contents of the options dictionary. It will then exit without
performing any copy operation.ditto doesn't copy directories into
directories in the same way as cp(1). In particular,
ditto foo barcp -r foo bar--keepParent for non-archive copies
will eventually alleviate this problem.
bom(5), lsbom(8), mkbom(8), cpio(1), zip(1), gzip(1), bzip2(1), tar(1).
ditto first appeared in Mac OS X
(10.0)
| June 1, 2022 | macOS 13.0 |