2 .\" Copyright (c) 1990, 1993
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Keith Muller of the University of California, San Diego.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)dd.1 8.2 (Berkeley) 1/13/94
40 .Nd convert and copy a file
47 utility copies the standard input to the standard output.
48 Input data is read and written in 512-byte blocks.
49 If input reads are short, input from multiple reads are aggregated
50 to form the output block.
53 displays the number of complete and partial input and output blocks
54 and truncated input records to the standard error output.
56 The following operands are available:
57 .Bl -tag -width "of=file"
58 .It Cm bs Ns = Ns Ar n
59 Set both input and output block size to
61 bytes, superseding the
66 If no conversion values other than
71 are specified, then each input block is copied to the output as a
72 single block without any aggregation of short blocks.
73 .It Cm cbs Ns = Ns Ar n
74 Set the conversion record size to
77 The conversion record size is required by the record oriented conversion
79 .It Cm count Ns = Ns Ar n
83 .It Cm files Ns = Ns Ar n
86 input files before terminating.
87 This operand is only applicable when the input device is a tape.
88 .It Cm fillchar Ns = Ns Ar c
89 When padding a block in conversion mode or due to use of
93 modes, fill with the specified
95 character, rather than using a space or
97 .It Cm ibs Ns = Ns Ar n
98 Set the input block size to
100 bytes instead of the default 512.
101 .It Cm if Ns = Ns Ar file
104 instead of the standard input.
105 .It Cm iflag Ns = Ns Ar value Ns Op , Ns Ar value ...
108 is one of the symbols from the following list.
109 .Bl -tag -width "fullblock"
111 Reading from the input file may not obtain a full block.
112 When a read returns short, continue reading to fill the block.
115 limits the number of times
117 is called on the input rather than the number of blocks copied in full.
118 May not be combined with
121 .It Cm iseek Ns = Ns Ar n
122 Seek on the input file
125 This is synonymous with
126 .Cm skip Ns = Ns Ar n .
127 .It Cm obs Ns = Ns Ar n
128 Set the output block size to
130 bytes instead of the default 512.
131 .It Cm of Ns = Ns Ar file
134 instead of the standard output.
135 Any regular output file is truncated unless the
137 conversion value is specified.
138 If an initial portion of the output file is seeked past (see the
141 the output file is truncated at that point.
142 .It Cm oflag Ns = Ns Ar value Ns Op , Ns Ar value ...
145 is one of the symbols from the following list.
146 .Bl -tag -width "fsync"
148 Set the O_FSYNC flag on the output file to make writes synchronous.
150 Set the O_SYNC flag on the output file to make writes synchronous.
151 This is synonymous with the
155 .It Cm oseek Ns = Ns Ar n
156 Seek on the output file
159 This is synonymous with
160 .Cm seek Ns = Ns Ar n .
161 .It Cm seek Ns = Ns Ar n
164 blocks from the beginning of the output before copying.
165 On non-tape devices, an
168 Otherwise, existing blocks are read and the data discarded.
169 If the user does not have read permission for the tape, it is positioned
173 If the seek operation is past the end of file, space from the current
174 end of file to the specified offset is filled with blocks of
177 .It Cm skip Ns = Ns Ar n
180 blocks from the beginning of the input before copying.
181 On input which supports seeks, an
184 Otherwise, input data is read and discarded.
185 For pipes, the correct number of bytes is read.
186 For all other devices, the correct number of blocks is read without
187 distinguishing between a partial or complete block being read.
188 .It Cm speed Ns = Ns Ar n
189 Limit the copying speed to
192 .It Cm status Ns = Ns Ar value
195 is one of the symbols from the following list.
196 .Bl -tag -width "progress"
198 Do not print the transfer statistics as the last line of status output.
200 Do not print the status output.
201 Error messages are shown; informational messages are not.
203 Print basic transfer statistics once per second.
205 .It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ...
208 is one of the symbols from the following list.
209 .Bl -tag -width "unblock"
210 .It Cm ascii , oldascii
213 value except that characters are translated from
218 records are converted.
224 There are two conversion maps for
228 specifies the recommended one which is compatible with
232 specifies the one used in historic
235 .No pre- Ns Bx 4.3 reno
238 Treats the input as a sequence of newline or end-of-file terminated variable
239 length records independent of input and output block boundaries.
240 Any trailing newline character is discarded.
241 Each input record is converted to a fixed length output record where the
242 length is specified by the
245 Input records shorter than the conversion record size are padded with spaces.
246 Input records longer than the conversion record size are truncated.
247 The number of truncated input records, if any, are reported to the standard
248 error output at the completion of the copy.
249 .It Cm ebcdic , ibm , oldebcdic , oldibm
252 value except that characters are translated from
257 records are converted.
263 There are four conversion maps for
267 specifies the recommended one which is compatible with
271 is a slightly different mapping, which is compatible with the
279 are maps used in historic
282 .No pre- Ns Bx 4.3 reno
287 on the output file before closing it.
291 on the output file before closing it.
293 Transform uppercase characters into lowercase characters.
294 .It Cm pareven , parnone , parodd , parset
295 Output data with the specified parity.
296 The parity bit on input is stripped unless
300 conversions is also specified.
302 Do not stop processing on an input error.
303 When an input error occurs, a diagnostic message followed by the current
304 input and output block counts will be written to the standard error output
305 in the same format as the standard completion message.
308 conversion is also specified, any missing input data will be replaced
311 bytes (or with spaces if a block oriented conversion value was
312 specified) and processed as a normal input buffer.
315 option is specified, the fill character provided on the command line
317 the automatic selection of the fill character.
320 conversion is not specified, the input block is omitted from the output.
321 On input files which are not tapes or pipes, the file offset
322 will be positioned past the block in which the error occurred using
325 Do not truncate the output file.
326 This will preserve any blocks in the output file not explicitly written
331 value is not supported for tapes.
333 Pad the final output block to the full output block size.
334 If the input file is not a multiple of the output block size
335 after conversion, this conversion forces the final output block
336 to be the same size as preceding blocks for use on devices that require
337 regularly sized blocks to be written.
338 This option is incompatible with use of the
340 block size specification.
342 If one or more output blocks would consist solely of
344 bytes, try to seek the output file by the required space instead of
347 resulting in a sparse file.
349 Swap every pair of input bytes.
350 If an input buffer has an odd number of bytes, the last byte will be
351 ignored during swapping.
353 Pad every input block to the input buffer size.
354 Spaces are used for pad bytes if a block oriented conversion value is
359 Transform lowercase characters into uppercase characters.
361 Treats the input as a sequence of fixed length records independent of input
362 and output block boundaries.
363 The length of the input records is specified by the
366 Any trailing space characters are discarded and a newline character is
371 Where sizes or speed are specified, a decimal, octal, or hexadecimal number of
373 If the number ends with a
383 number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G),
384 1099511627776 (1T), 1125899906842624 (1P)
385 or the number of bytes in an integer, respectively.
386 Two or more numbers may be separated by an
388 to indicate a product.
392 displays the number of complete and partial input and output blocks,
393 truncated input records and odd-length byte-swapping blocks to the
394 standard error output.
395 A partial input block is one where less than the input block size
397 A partial output block is one where less than the output block size
399 Partial output blocks to tape devices are considered fatal errors.
400 Otherwise, the rest of the block will be written.
401 Partial output blocks to character devices will produce a warning message.
402 A truncated input block is one where a variable length record oriented
403 conversion value was specified and the input line was too long to
404 fit in the conversion record or was not newline terminated.
406 Normally, data resulting from input or conversion or both are aggregated
407 into output blocks of the specified size.
408 After the end of input is reached, any remaining output is written as
410 This means that the final output block may be shorter than the output
421 signal, the current input and output block counts will
422 be written to the standard error output
423 in the same format as the standard completion message.
428 signal, the current input and output block counts will
429 be written to the standard error output
430 in the same format as the standard completion message and
436 Check that a disk drive contains no bad blocks:
438 .Dl "dd if=/dev/ada0 of=/dev/null bs=1m"
440 Do a refresh of a disk drive, in order to prevent presently
441 recoverable read errors from progressing into unrecoverable read errors:
443 .Dl "dd if=/dev/ada0 of=/dev/ada0 bs=1m"
445 Remove parity bit from a file:
447 .Dl "dd if=file conv=parnone of=file.txt"
449 Check for (even) parity errors on a file:
451 .Dl "dd if=file conv=pareven | cmp -x - file"
453 To create an image of a Mode-1 CD-ROM, which is a commonly used format
454 for data CD-ROM disks, use a block size of 2048 bytes:
456 .Dl "dd if=/dev/cd0 of=filename.iso bs=2048"
458 Write a filesystem image to a memory stick, padding the end with zeros,
459 if necessary, to a 1MiB boundary:
461 .Dl "dd if=memstick.img of=/dev/da0 bs=1m conv=noerror,sync"
472 utility is expected to be a superset of the
487 values are extensions to the
496 Protection mechanisms in the
498 subsystem might prevent the super-user from writing blocks to a disk.
499 Instructions for temporarily disabling these protection mechanisms can be