@pindex dd
@cindex converting while copying a file
-@command{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. Synopses:
+@command{dd} copies input to output with a changeable I/O block size,
+while optionally performing conversions on the data. Synopses:
@example
dd [@var{operand}]@dots{}
@end example
The only options are @option{--help} and @option{--version}.
-@xref{Common options}. @command{dd} accepts the following operands,
+@xref{Common options}.
+
+By default, @command{dd} copies standard input to standard output.
+To copy, @command{dd} repeatedly does the following steps in order:
+
+@enumerate
+@item
+Read an input block.
+
+@item
+If converting via @samp{sync}, pad as needed to meet the input block size.
+Pad with spaces if converting via @samp{block} or @samp{unblock}, NUL
+bytes otherwise.
+
+@item
+If @samp{bs=} is given and no conversion mentioned in steps (4) or (5)
+is given, output the data as a single block and skip all remaining steps.
+
+@item
+If the @samp{swab} conversion is given, swap each pair of input bytes.
+If the input data length is odd, preserve the last input byte
+(since there is nothing to swap it with).
+
+@item
+If any of the conversions @samp{swab}, @samp{block}, @samp{unblock},
+@samp{lcase}, @samp{ucase}, @samp{ascii}, @samp{ebcdic} and @samp{ibm}
+are given, do these conversions. These conversions operate
+independently of input blocking, and might deal with records that span
+block boundaries.
+
+@item
+Aggregate the resulting data into output blocks of the specified size,
+and output each output block in turn. Do not pad the last output block;
+it can be shorter than usual.
+@end enumerate
+
+@command{dd} accepts the following operands,
whose syntax was inspired by the DD (data definition) statement of
OS/360 JCL.
@opindex skip
@opindex iseek
Skip @var{n} @samp{ibs}-byte blocks in the input file before copying.
-If @samp{iflag=skip_bytes} is specified, @var{n} is interpreted
+With @samp{iflag=skip_bytes}, interpret @var{n}
as a byte count rather than a block count.
+(The @samp{iseek=} spelling is an extension to POSIX.)
@item seek=@var{n}
@itemx oseek=@var{n}
@opindex oseek
Skip @var{n} @samp{obs}-byte blocks in the output file before
truncating or copying.
-If @samp{oflag=seek_bytes} is specified, @var{n} is interpreted
+With @samp{oflag=seek_bytes}, interpret @var{n}
as a byte count rather than a block count.
+(The @samp{oseek=} spelling is an extension to POSIX.)
@item count=@var{n}
@opindex count
Copy @var{n} @samp{ibs}-byte blocks from the input file, instead
of everything until the end of the file.
-if @samp{iflag=count_bytes} is specified, @var{n} is interpreted
+With @samp{iflag=count_bytes}, interpret @var{n}
as a byte count rather than a block count.
-Note if the input may return short reads as could be the case
+If short reads occur, as could be the case
when reading from a pipe for example, @samp{iflag=fullblock}
-will ensure that @samp{count=} corresponds to complete input blocks
-rather than the traditional POSIX specified behavior of counting
-input read operations.
+ensures that @samp{count=} counts complete input blocks
+rather than input read operations.
+As an extension to POSIX, @samp{count=0} copies zero blocks
+instead of copying all blocks.
@item status=@var{level}
@opindex status
truncated records} is output after the @samp{records out} line if
@samp{conv=block} processing truncated one or more input records.
+The @samp{status=} operand is a GNU extension to POSIX.
+
@item conv=@var{conversion}[,@var{conversion}]@dots{}
@opindex conv
Convert the file as specified by the @var{conversion} argument(s).
and append a newline.
The @samp{block} and @samp{unblock} conversions are mutually exclusive.
+If you use either of these conversions, you should also use the
+@samp{cbs=} operand.
@item lcase
@opindex lcase@r{, converting to}
NUL input blocks are not copied, and therefore this conversion
is most useful with virtual or pre zeroed devices.
+The @samp{sparse} conversion is a GNU extension to POSIX.
+
@item swab
@opindex swab @r{(byte-swapping)}
@cindex byte-swapping
-Swap every pair of input bytes. GNU @command{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).
+Swap every pair of input bytes.
@item sync
@opindex sync @r{(padding with ASCII NULs)}
@cindex creating output file, avoiding
Do not create the output file; the output file must already exist.
-The @samp{excl} and @samp{nocreat} conversions are mutually exclusive.
+The @samp{excl} and @samp{nocreat} conversions are mutually exclusive,
+and are GNU extensions to POSIX.
@item notrunc
@opindex notrunc
Synchronize output data just before finishing,
even if there were write errors.
This forces a physical write of output data.
+This conversion is a GNU extension to POSIX.
@item fsync
@opindex fsync
Synchronize output data and metadata just before finishing,
even if there were write errors.
This forces a physical write of output data and metadata.
+This conversion is a GNU extension to POSIX.
@end table
Access the output file using the flags specified by the @var{flag}
argument(s). (No spaces around any comma(s).)
-Here are the flags. Not every flag is supported on every operating
-system.
+Here are the flags.
@table @samp
@end table
-These flags are not supported on all systems, and @samp{dd} rejects
+These flags are all GNU extensions to POSIX.
+They are not supported on all systems, and @samp{dd} rejects
attempts to use them when they are not supported. When reading from
standard input or writing to standard output, the @samp{nofollow} and
@samp{noctty} flags should not be specified, and the other flags
@end table
+The behavior of @command{dd} is unspecified if operands other than
+@samp{conv=}, @samp{iflag=}, @samp{oflag=}, and @samp{status=} are
+specified more than once.
+
@cindex multipliers after numbers
The numeric-valued strings above (@var{n} and @var{bytes})
+are unsigned decimal integers that
can be followed by a multiplier: @samp{b}=512, @samp{c}=1,
@samp{w}=2, @samp{x@var{m}}=@var{m}, or any of the
standard block size suffixes like @samp{k}=1024 (@pxref{Block size}).
+These multipliers are GNU extensions to POSIX, except that
+POSIX allows @var{bytes} to be followed by @samp{k}, @samp{b}, and
+@samp{x@var{m}}.
+Block sizes (i.e., specified by @var{bytes} strings) must be nonzero.
Any block size you specify via @samp{bs=}, @samp{ibs=}, @samp{obs=}, @samp{cbs=}
should not be too large---values larger than a few megabytes