dd copies a file (from standard input to standard output, by
default) using specific input and output blocksizes,
while optionally performing conversions on it.
It reads the input one block at a time, using the specified input
block size (the default is 512 bytes).
If the
bs=bytes option was given, and no conversion other than
sync, noerror, or notrunc was specified, it writes the amount of data read (which could be smaller
than what was requested) in a separate output block. This output block
has precisely the same length as was read unless the
sync conversion was specified, in which case the data is padded with null
bytes (NUL, \0;
or with spaces, see below).
Otherwise, the input, read one block at a time, is processed
and the resulting output is collected and written in blocks
of the specified output block size. The final output block
may be shorter.
The numeric-valued options below (bytes and blocks) can be followed
by a multiplier: k=1024, b=512, w=2, c=1
(w and c are GNU extensions; w should never be used -
it means 2 in System V and 4 in 4.2BSD).
Two or more of such numeric expressions can be multiplied
by putting x in between.
The GNU fileutils-4.0 version also allows the following multiplicative suffixes
in the specification of blocksizes (in bs=, cbs=, ibs=, obs=):
M=1048576, G=1073741824, and so on for T, P, E, Z, Y.
A D suffix makes them decimal:
kD=1000, MD=1000000, GD=1000000000, etc.
(Note that for ls, df, du the size of M etc. is determined by environment
variables, but for dd it is fixed.)
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. The default is 512.
obs=bytes
Write
bytes bytes at a time. The default is 512.
bs=bytes
Both read and write
bytes bytes at a time. This overrides
ibs and
obs. (And setting
bs is not equivalent with setting both
ibs and
obs to this same value, at least when no conversion other than
sync,
noerror and
notrunc is specified, since it stipulates that each input block
shall be copied to the output as a single block
without aggregating short blocks.)
cbs=bytes
Specify the conversion block size for
block and
unblock.
skip=blocks
Skip
blocksibs-byte blocks in the input file before copying.
seek=blocks
Skip
blocksobs-byte blocks in the output file before copying.
count=blocks
Copy
blocksibs-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.
If an odd number of bytes are read the last byte
is simply copied (since there is nothing to swap it with).
[POSIX.2b, PASC interpretations 1003.2 #3 and #4]
noerror
Continue after read errors.
notrunc
Do not truncate the output file.
sync
Pad every input block to size of
ibs with trailing null bytes (\0).
Often a tape drive will not accept arbitrarily sized blocks, and
dd would get an I/O error for the last fragment of data that does not
fill an entire block. Use dd if=myfile of=/dev/mytape conv=sync
to get everything on tape. Of course, reading it back will now
produce a slightly larger file, with null bytes added at the end.
Commands like dd if=myfile of=/dev/fd0 bs=1k seek=172 fail
on some systems because
dd tries to truncate the output file, but truncation of a block device
is not possible. In such cases, add the conv=notrunc option.