[Next] [Previous] [Up] [Top] [Contents]

8.2 File Archiving, Compression and Conversion

8.2.4 dd - block copy and convert

The dd command allows you to copy from raw devices, such as disks and tapes, specifying the input and output block sizes. dd was originally known as the disk-to-disk copy program. With dd you can also convert between different formats, for example, EBCDIC to ASCII, or swap byte order, etc.

Syntax

dd [if=input_device] [of=output_device] [operand=value]

Common Options

if=input_device the input file or device

of=output_device the output file or device

If the input or output devices are not specified they default to standard input and standard output, respectively.

Operands can include:

ibs=n input block size (defaults to 512 byte blocks)

obs=n output block size (defaults to 512 byte blocks)

bs=n sets both input and output block sizes

files=n copy n input files

skip=n skip n input blocks before starting to copy

count=n only copy n input blocks

conv=value[,value] where value can include:

ascii convert EBCDIC to ASCII

ebcdic convert from ASCII to EBCDIC

lcase convert upper case characters to lower case

ucase convert lower case characters to upper case

swab swap every pair of bytes of input data

noerror don't stop processing on an input error

sync pad every input block to the size of ibs, appending null bytes as needed

Block sizes are specified in bytes and may end in k, b, or w to indicate 1024 (kilo), 512 (block), or 2 (word), respectively.

Examples

To copy files from one tape drive to another:

% dd if=/dev/rmt/0 of=/dev/rmt/1

20+0 records in

20+0 records out

To copy files written on a tape drive on a big endian machine, written with a block size of 20 blocks, to a file on a little endian machine that now has the tape inserted in its drive, we would need to swap pairs of bytes, as in:

% dd if=/dev/rmt/0 of=new_file ibs=20b conv=swab

1072+0 records in

21440+0 records out

Upon completion dd reports the number of whole blocks and partial blocks for both the input and output files.


Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]