1.\" $OpenBSD: dd.1,v 1.39 2020/10/29 07:01:24 jmc Exp $ 2.\" $NetBSD: dd.1,v 1.5 1995/03/21 09:04:04 cgd Exp $ 3.\" 4.\" Copyright (c) 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" Keith Muller of the University of California, San Diego. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)dd.1 8.2 (Berkeley) 1/13/94 35.\" 36.Dd $Mdocdate: October 29 2020 $ 37.Dt DD 1 38.Os 39.Sh NAME 40.Nm dd 41.Nd convert and copy a file 42.Sh SYNOPSIS 43.Nm dd 44.Op Ar operand ... 45.Sh DESCRIPTION 46The 47.Nm 48utility copies the standard input to the standard output, applying any 49specified conversions. 50Input data is read and written in 512-byte blocks. 51If input reads are short, input from multiple reads are aggregated 52to form the output block. 53When finished, 54.Nm 55displays the number of complete and partial input and output blocks 56and truncated input records to the standard error output. 57.Pp 58The following operands are available: 59.Bl -tag -width of=file 60.It Cm if Ns = Ns Ar file 61Read input from 62.Ar file 63instead of the standard input. 64.It Cm of Ns = Ns Ar file 65Write output to 66.Ar file 67instead of the standard output. 68Any regular output file is truncated unless the 69.Cm notrunc 70conversion value is specified. 71If an initial portion of the output file is skipped (see the 72.Cm seek 73operand), 74the output file is truncated at that point. 75.It Cm ibs Ns = Ns Ar n 76Set the input block size to 77.Ar n 78bytes instead of the default 512. 79.It Cm obs Ns = Ns Ar n 80Set the output block size to 81.Ar n 82bytes instead of the default 512. 83.It Cm bs Ns = Ns Ar n 84Set both the input and output block size to 85.Ar n 86bytes, superseding the 87.Cm ibs 88and 89.Cm obs 90operands. 91If no conversion values other than 92.Cm noerror , 93.Cm notrunc , 94or 95.Cm sync 96are specified, then each input block is copied to the output as a 97single block without any aggregation of short blocks. 98.It Cm cbs Ns = Ns Ar n 99Set the conversion record size to 100.Ar n 101bytes. 102The conversion record size is required by the record oriented conversion 103values. 104.It Cm count Ns = Ns Ar n 105Copy only 106.Ar n 107input blocks. 108.It Cm files Ns = Ns Ar n 109Copy 110.Ar n 111input files before terminating. 112This operand is only applicable when the input device is a tape. 113.It Cm seek Ns = Ns Ar n 114Seek 115.Ar n 116blocks from the beginning of the output before copying. 117On non-tape devices, an 118.Xr lseek 2 119operation is used. 120Otherwise, existing blocks are read and the data discarded. 121If the user does not have read permission for the tape, it is positioned 122using the tape 123.Xr ioctl 2 124function calls. 125If the seek operation is past the end of file, space from the current 126end of file to the specified offset is filled with blocks of NUL bytes. 127.It Cm skip Ns = Ns Ar n 128Skip 129.Ar n 130blocks from the beginning of the input before copying. 131On input which supports seeks, an 132.Xr lseek 2 133operation is used. 134Otherwise, input data is read and discarded. 135For pipes, the correct number of bytes is read. 136For all other devices, the correct number of blocks is read without 137distinguishing between a partial or complete block being read. 138.It Cm status Ns = Ns Ar value 139The 140.Ar value 141is one of the symbols from the following list: 142.Bl -tag -width unblock 143.It Cm noxfer 144Do not print the transfer statistics as the last line of status output. 145.It Cm none 146Do not print the status output. 147Error messages are shown; informational messages are not. 148.El 149.It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ... 150Each 151.Ar value 152is one of the symbols from the following list: 153.Bl -tag -width unblock 154.It Cm ascii 155The same as the 156.Cm unblock 157value except that characters are translated from EBCDIC to ASCII 158before the records are converted. 159(These values imply 160.Cm unblock 161if the operand 162.Cm cbs 163is also specified.) 164.It Cm block 165Treats the input as a sequence of newline or end-of-file terminated variable 166length records independent of input and output block boundaries. 167Any trailing newline character is discarded. 168Each input record is converted to a fixed length output record where the 169length is specified by the 170.Cm cbs 171operand. 172Input records shorter than the conversion record size are padded with spaces. 173Input records longer than the conversion record size are truncated. 174The number of truncated input records, if any, is reported to the standard 175error output at the completion of the copy. 176.It Cm ebcdic , ibm 177The same as the 178.Cm block 179value except that characters are translated from ASCII to EBCDIC 180after the records are converted. 181(These values imply 182.Cm block 183if the operand 184.Cm cbs 185is also specified.) 186There are two conversion maps for EBCDIC. 187The value 188.Cm ebcdic 189specifies the recommended one which is compatible with 190.At V . 191The value 192.Cm ibm 193is a slightly different mapping, which is compatible with the 194.At V 195.Cm ibm 196value. 197.It Cm fsync 198Call 199.Xr fsync 2 200on the output file before exiting. 201.It Cm lcase 202Transform uppercase characters into lowercase characters. 203.It Cm noerror 204Do not stop processing on an input error. 205When an input error occurs, a diagnostic message followed by the current 206input and output block counts will be written to the standard error output 207in the same format as the standard completion message. 208If the 209.Cm sync 210conversion is also specified, any missing input data will be replaced 211with NUL bytes (or with spaces if a block oriented conversion value was 212specified) and processed as a normal input buffer. 213If the 214.Cm sync 215conversion is not specified, the input block is omitted from the output. 216On input files which are not tapes or pipes, the file offset 217will be positioned past the block in which the error occurred using 218.Xr lseek 2 . 219.It Cm notrunc 220Do not truncate the output file. 221This will preserve any blocks in the output file not explicitly written 222by 223.Nm dd . 224The 225.Cm notrunc 226value is not supported for tapes. 227.It Cm osync 228Pad the final output block to the full output block size. 229This forces the final output block to be the same size 230as preceding blocks for use on devices that require 231regularly sized blocks to be written. 232This option is incompatible with the 233.Cm bs 234block size specification. 235.It Cm swab 236Swap every pair of input bytes. 237If an input buffer has an odd number of bytes, the last byte will be 238ignored during swapping. 239.It Cm sync 240Pad every input block to the input buffer size. 241Spaces are used for pad bytes if a block oriented conversion value is 242specified, otherwise NUL bytes are used. 243.It Cm ucase 244Transform lowercase characters into uppercase characters. 245.It Cm unblock 246Treats the input as a sequence of fixed length records independent of input 247and output block boundaries. 248The length of the input records is specified by the 249.Cm cbs 250operand. 251Any trailing space characters are discarded and a newline character is 252appended. 253.El 254.El 255.Pp 256Where sizes are specified, a decimal number of bytes is expected. 257If the number ends with a 258.Sq b , 259.Sq k 260or 261.Sq K , 262.Sq m 263or 264.Sq M , 265.Sq g 266or 267.Sq G , 268or 269.Sq w , 270the number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G), 271or the number of bytes in an integer, respectively. 272Two or more numbers may be separated by an 273.Sq x 274to indicate a product. 275.Pp 276When finished, 277.Nm 278displays the number of complete and partial input and output blocks, 279truncated input records, and odd-length byte-swapping blocks to the 280standard error output. 281A partial input block is one where less than the input block size 282was read. 283A partial output block is one where less than the output block size 284was written. 285Partial output blocks to tape devices are considered fatal errors. 286Otherwise, the rest of the block will be written. 287Partial output blocks to character devices will produce a warning message. 288A truncated input block is one where a variable length record oriented 289conversion value was specified and the input line was too long to 290fit in the conversion record or was not newline terminated. 291.Pp 292Normally, data resulting from input or conversion or both are aggregated 293into output blocks of the specified size. 294After the end of input is reached, any remaining output is written as 295a block. 296This means that the final output block may be shorter than the output 297block size. 298.Pp 299If 300.Nm 301receives a 302.Dv SIGINFO 303(see the 304.Dq status 305argument for 306.Xr stty 1 ) 307signal, the current input and output block counts will 308be written to the standard error output 309in the same format as the standard completion message. 310If 311.Nm 312receives a 313.Dv SIGINT 314signal, the current input and output block counts will 315be written to the standard error output 316in the same format as the standard completion message and 317.Nm 318will exit. 319.Sh EXIT STATUS 320.Ex -std dd 321.Sh EXAMPLES 322Write a bootable 323.Ox 324disk image to a USB flash drive attached at 325.Pa /dev/sd3 : 326.Pp 327.Dl # dd if=install68.img of=/dev/rsd3c bs=1m 328.Pp 329Create an ISO-9660 image of a CD-ROM: 330.Pp 331.Dl # dd if=/dev/rcd0c of=disk.iso bs=32k 332.Sh SEE ALSO 333.Xr cp 1 , 334.Xr mt 1 , 335.Xr tr 1 336.Sh STANDARDS 337The 338.Nm 339utility is compliant with the 340.St -p1003.1-2008 341specification. 342.Pp 343The conversions 344.Cm ascii , 345.Cm ebcdic , 346and 347.Cm ibm 348are marked by 349.St -p1003.1-2008 350as being an 351X/Open System Interfaces option. 352.Pp 353The 354.Cm files 355and 356.Cm status 357operands, 358the 359.Cm fsync 360and 361.Cm osync 362conversions, 363the 364.Sq K , 365.Sq m , 366.Sq M , 367.Sq g , 368.Sq G , 369and 370.Sq w 371size multipliers 372and 373.Dv SIGINFO 374handling 375are all extensions to the 376.St -p1003.1-2008 377specification. 378.Sh HISTORY 379A 380.Nm 381utility appeared in 382.At v5 . 383