[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.2 dd: Convert and copy a file

dd copies a file (from standard input to standard output, by default) with a changeable I/O block size, while optionally performing conversions on it. Synopsis:

 
dd [option]...

The program accepts the following options. Also see 2. Common options.

The numeric-valued options below (bytes and blocks) can be followed by a multiplier: `b'=512, `c'=1, `w'=2, `xm'=m, or any of the standard block size suffixes like `k'=1024 (see section 2.2 Block size).

Use different dd invocations to use different block sizes for skipping and I/O. For example, the following shell commands copy data in 512 KiB blocks between a disk and a tape, but do not save or restore a 4 KiB label at the start of the disk:

 
disk=/dev/rdsk/c0t1d0s2
tape=/dev/rmt/0

# Copy all but the label from disk to tape.
(dd bs=4k skip=1 count=0 && dd bs=512k) <$disk >$tape

# Copy from tape back to disk, but leave the disk label alone.
(dd bs=4k seek=1 count=0 && dd bs=512k) <$tape >$disk

`if=file'
Read from file instead of standard input.

`of=file'
Write to file instead of standard output. Unless `conv=notrunc' is given, dd truncates file to zero bytes (or the size specified with `seek=').

`ibs=bytes'
Read bytes bytes at a time.

`obs=bytes'
Write bytes bytes at a time.

`bs=bytes'
Both read and write bytes bytes at a time. This overrides `ibs' and `obs'.

`cbs=bytes'
Convert bytes bytes at a time.

`skip=blocks'
Skip blocks `ibs'-byte blocks in the input file before copying.

`seek=blocks'
Skip blocks `obs'-byte blocks in the output file before copying.

`count=blocks'
Copy blocks `ibs'-byte blocks from the input file, instead of everything until the end of the file.

`conv=conversion[,conversion]...'
Convert the file as specified by the conversion argument(s). (No spaces around any comma(s).)

Conversions:

`ascii'
Convert EBCDIC to ASCII.

`ebcdic'
Convert ASCII to EBCDIC.

`ibm'
Convert ASCII to alternate EBCDIC.

`block'
For each line in the input, output `cbs' bytes, replacing the input newline with a space and padding with spaces as necessary.

`unblock'
Replace trailing spaces in each `cbs'-sized input block with a newline.

`lcase'
Change uppercase letters to lowercase.

`ucase'
Change lowercase letters to uppercase.

`swab'
Swap every pair of input bytes. GNU dd, unlike others, works when an odd number of bytes are read--the last byte is simply copied (since there is nothing to swap it with).

`noerror'
Continue after read errors.

`notrunc'
Do not truncate the output file.

`sync'
Pad every input block to size of `ibs' with trailing zero bytes. When used with `block' or `unblock', pad with spaces instead of zero bytes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Jeff Bailey on December, 28 2002 using texi2html