Next: Examples
Up: ddthe data duplicator
Previous: ddthe data duplicator
To say the truth, dd it's not completely unlike the other Unix
command: it is indeed a filter, that is it reads by default from the
standard input and writes to the standard output. So if you just type dd
at the terminal it remains quiet, waiting for input, and a ctrl-C is the
only sensitive thing to type.
The syntax of the command is as follows:
dd [if=file] [of=file] [ibs=bytes] [obs=bytes]
[bs=bytes] [cbs=bytes] [skip=blocks] [seek=blocks]
[count=blocks] [conv={ascii,ebcdic,ibm,block,
unblock,lcase,ucase,swab,noerror,notrunc,sync}]
so all options are of the form option=value. No space is allowed either
before or after the equal sign; this used to be annoying, because the
shell did not expand a filename in this situation, but the version of bash
present in Linux is rather smart, so you don't have to worry about that.
It is important also to remember that all numbered values (bytes and
blocks above) can be followed by a multiplier. The possible choices
are b for block, which multiplies by 512, k for kilobytes
(1024), w for word (2), and xm multiplies by m.
The meaning of options if explained below.
- if=filein and of=fileout instruct
dd to respectively read from filein and write to fileout.
In the latter case, the output file is truncated to the value given to
seek, or if the keyword is not present, to 0 (that is deleted), before
performing the operation. But look below at option notrunc.
- ibs=nn and obs=nn specify how much
bytes should be read or write at a time. I think that the default is 1
block, i.e. 512 bytes, but I am not very sure about it: certainly it works
that way with plain files. These parameters are very
important when using special devices as input or output; for example,
reading from the net should set ibs at 10k, while a high density
3.5'' floppy has as its natural block size 18k. Failing to set these
values could result not only in longer time to perform the command, but
even in timeout errors, so be careful.
- bs=nn both reads and writes nn bytes at a time.
It overrides ibs and obs keywords.
- cbs=nn sets the conversion buffers to nn
bytes. This buffer is used when translating from ASCII to EBCDIC, or from
an unblocked device to a blocked one. For example, files created under VMS
have often a block size of 512, so you have to set cbs to 1b when
reading a foreign VMS tape. Hope that you don't have to mess
with these things!
- skip=nbl and seek=nbl tell the program to
skip nbl blocks respectively at the beginning of input and at the
beginning of output. Of course the latter case makes sense if conversion
notrunc is given, see below. Each block's size is the value of
ibs (obs). Beware: if you did not set ibs and write
skip=1b you are actually skipping 512
512 bytes, that is 256KB. It
was not precisely what you wanted, wasn't it? - count=nbl means to copy only nbl blocks from
input, each of the size given by ibs. This option, together with the
previous, turns useful if for example you have a corrupted file and you
want to recover how much it is possible from it. You just skip the
unreadable part and get what remains.
- conv=conversion,[conversion...] convert the
file as specified by its argument. Possible conversions are ascii,
which converts from EBCDIC to ASCII; ebcdic and ibm, which both
perform an inverse conversion (yes, there is not a unique conversion from
EBCDIC to ASCII! The first is the standard one, but the second works
better when printing files on a IBM printer); block, which pads
newline-terminated records to the size of cbs, replacing newline with
trailing spaces; unblock, which performs the opposite (eliminates
trailing spaces, and replaces them with newline); lcase and
ucase, to convert test to lowercase and uppercase; swab, which
swaps every pair of input bytes (for example, to use a file containing
short integers written on a 680x0 machine in an Intel-based machine you
need such a conversion); noerror, to continue processing after read
errors; sync, which pads input block to the size of ibs with
trailing NULs.
Next: Examples
Up: ddthe data duplicator
Previous: ddthe data duplicator
Converted on:
Mon Apr 1 08:59:56 EST 1996