DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

dd(C)


dd -- convert and copy a file

Syntax

dd [ option=value ] ...

Description

dd copies the specified input file to the specified output with possible conversions. The standard input and output are used by default. The input and output block size may be specified to take advantage of raw physical I/O.

if=file
Input filename; standard input is default.

of=file
Output filename; standard output is default. This option truncates an existing file to zero bytes in length unless conv=notrunc is specified.

ibs=n
Input block size is n bytes (default is BSIZE block size).

obs=n
Output block size (default is BSIZE block size).

bs=n
Sets both input and output block size, superseding ibs and obs. If no conversion is specified, it is particularly efficient since no in-core copy needs to be done.

cbs=n
Conversion buffer size.

skip=n
Skips n input records before starting copy. (The records are read but not output.)

seek=n
Seeks n records from beginning of output file before copying.

iseek=n
Same as skip, but seeks over the records instead of reading them.

oseek=n
As for seek.

files=n
Specify the number of input files to concatenate. This option effectively causes a sequence of n EOFs to be ignored. (It is generally only useful for tape.)

count=n
Copies only n input records.

conv=value
value may be one or more (comma-separated) of the following:

block
Convert ASCII to unblocked ASCII.

unblock
Convert unblocked ASCII to ASCII.

bmode
Put the named device (whether block or character) into block mode. This is desirable for access to devices with capacity beyond 2GB. If you specify block size (bs) with bmode, it must be a multiple of 512-byte blocks.

ascii
Converts EBCDIC to ASCII.

ebcdic
Converts ASCII to EBCDIC.

ibm
Slightly different map of ASCII to EBCDIC.

immap
Input is to be memory mapped. (Input must be a regular file or block special device.)

lcase
Maps alphabetic characters to lowercase.

mmap
Input and output are to be memory mapped. (Both input and output must be a regular file or block special device.)

ommap
Output is to be memory mapped. (Both input and output must be a regular file or block special device.)

ucase
Maps alphabetic characters to uppercase.

swab
Swaps every pair of bytes.

noerror
Does not stop processing on an error.

notrunc
Do not truncate the output file. dd preserves existing blocks in the output file that are not written to explicitly.

sync
Pads every input record to ibs. Nulls are used for the pad character unless conv=block or conv=unblock has been specified, in which case spaces are used.

... , ...
Several comma-separated conversions.
Where sizes are specified, a number of bytes is expected. A number may end with k, b, or w to specify multiplication by 1024, 512, or 2 respectively; a pair of numbers may be separated by x to indicate a product.

cbs is used only if ascii, ebcdic, or ibm conversion is specified. In the former case, cbs characters are placed into the conversion buffer, converted to ASCII, and trailing blanks trimmed and newline added before sending the line to the output. In the latter two cases, ASCII characters are read into the conversion buffer, converted to EBCDIC, and blanks added to make up an output record of size cbs.

After completion, dd reports the number of whole and partial input and output blocks.

Exit values

dd returns the following values:

0
the input file was copied successfully

>0
an error occurred

Diagnostics


f+p records in
Numbers of full and partial blocks read in the current input block size.

f+p records out
Numbers of full and partial blocks written in the current output block size.

n truncated records
Numbers of blocks that were truncated because they overflowed the conversion buffer.

These messages are written to the standard error output.

Examples

The first example reads an EBCDIC tape, blocked ten 80-byte EBCDIC card images per record, into the ASCII file outfile:

dd if=/dev/rct0 of=outfile ibs=800 cbs=80 conv=ascii,lcase

Note the use of raw magtape. dd is especially suited to I/O on raw physical devices because it allows reading and writing in arbitrary record sizes.

The next example shows how to copy the contents of one floppy disk to another, using /tmp as a temporary storage area. The source disk is inserted in the drive, and the following command entered:

dd if=/dev/rfd0 of=/tmp/tempfile

Next the source disk is removed from the drive, and the destination disk inserted. The data in the temporary file, /tmp/tempfile, may now be copied to this disk:

dd if=/tmp/tempfile of=/dev/rfd0

Finally remove the temporary file:

rm /tmp/tempfile

To archive onto block devices (divisions. partitions, or whole disks) larger than 2GB, pipe cpio(C) output through the dd command:

find . -depth -print | cpio -ovcC8192 | dd of=/dev/my_spare_division conv=bmode bs=8k

To read an archive from a block device larger than 2GB, read the data with the dd command and pipe its output to the cpio(C) command:

dd if=/dev/my_spare_division conv=bmode bs=8k | cpio -ivcC8192

Limitations

Previous versions of dd did not truncate an existing output file. Existing scripts that rely on this functionality should be amended to use the conversion conv=notrunc.

The ASCII/EBCDIC conversion tables are taken from the 256-character standard in the CACM Nov, 1968. The ibm conversion corresponds better to certain IBM print train conventions. There is no universal solution.

Newlines are inserted only on conversion to ASCII; padding is done only on conversion to EBCDIC.

When using dd with a raw device, specify the block size as a multiple of 1KB. For example, to use a 9KB block size, enter:

dd if=file of=/dev/rct0 bs=18b

You could also enter:

dd if=file of=/dev/rct0 bs=9k

Open UNIX 8 compatibility notes

When running ACP on Open UNIX 8 and UnixWare 7 systems, set OSRCMDS=on to use the SCO OpenServer version of the <dd> command. This provides the expected behaviors for SCO OpenServer applications. The SCO OpenServer version of this command is also provided on Open UNIX 8 systems under the OSP feature See the Running SCO OpenServer Applications topic in the Open UNIX 8 documentation set.

See also

copy(C), cp(C), tar(C)

Standards conformance

dd is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003