ditto(8) BSD System Manager's Manual ditto(8)
NAME
ditto - copy files and directories to a destination directory
SYNOPSIS
ditto [-v] [-V] [-X] [--arch arch] [--bom bom] [--rsrc] src ... dst_directory ditto [-v] [-V] [--arch arch] [--rsrc] src_file dst_file ditto -c [-z] [-k] [-v] [-V] [-X] [--keepParent] src dst_archive ditto -x [-z] [-k] [-v] [-V] src_archive ... dst_directory
DESCRIPTION
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 path- name. The final forms reflect ditto's ability to create and unpack 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 (to) stdin (stdout). ditto overwrites existing files, symbolic links, and devices in the des- tination 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, or group of existing directories in the destination. Files cannot overwrite directo- ries or vice-versa. ditto can be used to "thin" multi-architecture binaries during a copy. ditto can also copy files selectively based on the contents of a BOM ("Bill of Materials") file. ditto preserves hardlinks present in the source directories and preserves setuid and setgid modes. Finally, ditto can preserve resource fork and HFS meta-data information when copying.
OPTIONS
-v Print a line of output for each source directory copied. -V Print a line of output for every file, symbolic link, and device copied. -X When copying one or more source directories, do not descend into directories that have a different device ID. -c create an archive at the destination path. 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. PKZip archives should be stored in filenames ending in .zip. -x the first source is an archive to extract. -z -x implies -z. CPIO archives should be compressed. Uncompressed data flows through the decompressor unmodified. -k Instead of CPIO, assume PKZip archives. --keepParent the parent directory of src should be embedded in dst_archive. --keepParent only applies to the creation of archives. --arch arch Thin multi-architecture binaries ("fat binaries") to the specified architecture. If multiple -arch options are specified then the resulting destination file will be multi-architectural containing each of the specified architectures (if they are present in the source file). arch should be specified as "ppc", "i386", etc. --bom bom If this option is given then only files, links, devices, and direc- tories that are present in the specified BOM file are copied. --rsrc Preserve resource forks and HFS meta-data. ditto will store this data in Carbon-compatible ._ AppleDouble files on filesystems that do not natively support resource forks. -rsrcFork synonym for --rsrc --sequesterRsrc ditto will preserve resource forks and HFS meta-data in the direc- tory __MACOSX within PKZip archives.
EXAMPLES
The command: ditto src_directory dst_directory copies the contents of src_directory into dst_directory, creating dst_directory if it does not already exist. The command: ditto src_directory dir/dst_directory copies the contents of src_directory into dir/dst_directory, creating dir and dst_directory if they don't already exist. The command: ditto src-1 ... src-n dst_directory copies the contents of all of the src directories into dst_directory, creating dst_directory if it does not already exist. The command: ditto --arch ppc fat_file thin_file copies the contents of fat_file into thin_file, thinning executable code to ppc-only on the fly. The command: ditto -c --rsrc Scripts -|ssh rhost ditto -x --rsrc - ./Scripts copies Scripts, including resources and metaData, to rhost.
ERRORS
ditto returns 0 if a copy finishes successfully, otherwise non-zero. Diagnostic messages will be printed to standard error.
ENVIRONMENT
DITTOABORT If the environment variable DITTOABORT is set, ditto will call abort(3) if it encounters a fatal error.
BUGS
ditto does not copy pipes; it should. ditto cannot copy multiple sources into a CPIO archive (that this doesn't work for PKZip is expected given that file format). ditto doesn't copy directories into directories in the same way as cp(1). In particular, ditto foo bar will copy the contents of foo into bar, whereas cp -r foo bar copies foo itself into bar. Though this is not a bug, some may consider this bug-like behavior. ditto should use getopt(3).
SEE ALSO
bom(5), lsbom(8), cpio(1), zip(1), tar(1), mkbom(8). Mac OS X 27 February 2003 Mac OS X
Mac OS X 10.3 - Generated Sat Jun 7 05:39:02 CDT 2008