1.\" $OpenBSD: dd.1,v 1.23 2009/05/12 20:39:51 schwarze 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: May 12 2009 $ 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 Ar file 61Read input from 62.Ar file 63instead of the standard input. 64.It Cm of= 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 Ar n 76Set the input block size to 77.Ar n 78bytes instead of the default 512. 79.It Cm obs= Ns Ar n 80Set the output block size to 81.Ar n 82bytes instead of the default 512. 83.It Cm bs= 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 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 Ar n 105Copy only 106.Ar n 107input blocks. 108.It Cm files= 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 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 127.Tn NUL 128bytes. 129.It Cm skip= Ns Ar n 130Skip 131.Ar n 132blocks from the beginning of the input before copying. 133On input which supports seeks, an 134.Xr lseek 2 135operation is used. 136Otherwise, input data is read and discarded. 137For pipes, the correct number of bytes is read. 138For all other devices, the correct number of blocks is read without 139distinguishing between a partial or complete block being read. 140.It Xo 141.Sm off 142.Cm conv= Ar value Oo , 143.Sm on 144.Ar value ... Oc 145.Xc 146Where 147.Ar value 148is one of the symbols from the following list. 149.Bl -tag -width unblock 150.It Cm ascii , oldascii 151The same as the 152.Cm unblock 153value except that characters are translated from 154.Tn EBCDIC 155to 156.Tn ASCII 157before the 158records are converted. 159(These values imply 160.Cm unblock 161if the operand 162.Cm cbs 163is also specified.) 164There are two conversion maps for 165.Tn ASCII . 166The value 167.Cm ascii 168specifies the recommended one which is compatible with System V. 169The value 170.Cm oldascii 171specifies the one used in historic 172.Tn AT&T 173and pre-4.3BSD-reno systems. 174.It Cm block 175Treats the input as a sequence of newline or end-of-file terminated variable 176length records independent of input and output block boundaries. 177Any trailing newline character is discarded. 178Each input record is converted to a fixed length output record where the 179length is specified by the 180.Cm cbs 181operand. 182Input records shorter than the conversion record size are padded with spaces. 183Input records longer than the conversion record size are truncated. 184The number of truncated input records, if any, is reported to the standard 185error output at the completion of the copy. 186.It Cm ebcdic , ibm , oldebcdic , oldibm 187The same as the 188.Cm block 189value except that characters are translated from 190.Tn ASCII 191to 192.Tn EBCDIC 193after the 194records are converted. 195(These values imply 196.Cm block 197if the operand 198.Cm cbs 199is also specified.) 200There are four conversion maps for 201.Tn EBCDIC . 202The value 203.Cm ebcdic 204specifies the recommended one which is compatible with 205.At V . 206The value 207.Cm ibm 208is a slightly different mapping, which is compatible with the 209.At V 210.Cm ibm 211value. 212The values 213.Cm oldebcdic 214and 215.Cm oldibm 216are maps used in historic 217.Tn AT&T 218and pre-4.3BSD-reno systems. 219.It Cm lcase 220Transform uppercase characters into lowercase characters. 221.It Cm noerror 222Do not stop processing on an input error. 223When an input error occurs, a diagnostic message followed by the current 224input and output block counts will be written to the standard error output 225in the same format as the standard completion message. 226If the 227.Cm sync 228conversion is also specified, any missing input data will be replaced 229with 230.Tn NUL 231bytes (or with spaces if a block oriented conversion value was 232specified) and processed as a normal input buffer. 233If the 234.Cm sync 235conversion is not specified, the input block is omitted from the output. 236On input files which are not tapes or pipes, the file offset 237will be positioned past the block in which the error occurred using 238.Xr lseek 2 . 239.It Cm notrunc 240Do not truncate the output file. 241This will preserve any blocks in the output file not explicitly written 242by 243.Nm dd . 244The 245.Cm notrunc 246value is not supported for tapes. 247.It Cm osync 248Pad the final output block to the full output block size. 249If the input file is not a multiple of the output block size 250after conversion, this conversion forces the final output block 251to be the same size as preceding blocks for use on devices that require 252regularly sized blocks to be written. 253This option is incompatible with use of the 254.Cm bs= Ns Ar n 255block size specification. 256.It Cm swab 257Swap every pair of input bytes. 258If an input buffer has an odd number of bytes, the last byte will be 259ignored during swapping. 260.It Cm sync 261Pad every input block to the input buffer size. 262Spaces are used for pad bytes if a block oriented conversion value is 263specified, otherwise 264.Tn NUL 265bytes are used. 266.It Cm ucase 267Transform lowercase characters into uppercase characters. 268.It Cm unblock 269Treats the input as a sequence of fixed length records independent of input 270and output block boundaries. 271The length of the input records is specified by the 272.Cm cbs 273operand. 274Any trailing space characters are discarded and a newline character is 275appended. 276.El 277.El 278.Pp 279Where sizes are specified, a decimal number of bytes is expected. 280If the number ends with a 281.Sq b , 282.Sq k , 283.Sq m , 284or 285.Sq w , 286the number 287is multiplied by 512, 1024 (1K), 1048576 (1M), or the number of bytes 288in an integer, respectively. 289Two or more numbers may be separated by an 290.Sq x 291to indicate a product. 292.Pp 293When finished, 294.Nm 295displays the number of complete and partial input and output blocks, 296truncated input records, and odd-length byte-swapping blocks to the 297standard error output. 298A partial input block is one where less than the input block size 299was read. 300A partial output block is one where less than the output block size 301was written. 302Partial output blocks to tape devices are considered fatal errors. 303Otherwise, the rest of the block will be written. 304Partial output blocks to character devices will produce a warning message. 305A truncated input block is one where a variable length record oriented 306conversion value was specified and the input line was too long to 307fit in the conversion record or was not newline terminated. 308.Pp 309Normally, data resulting from input or conversion or both are aggregated 310into output blocks of the specified size. 311After the end of input is reached, any remaining output is written as 312a block. 313This means that the final output block may be shorter than the output 314block size. 315.Pp 316If 317.Nm 318receives a 319.Dv SIGINFO 320(see the 321.Dq status 322argument for 323.Xr stty 1 ) 324signal, the current input and output block counts will 325be written to the standard error output 326in the same format as the standard completion message. 327If 328.Nm 329receives a 330.Dv SIGINT 331signal, the current input and output block counts will 332be written to the standard error output 333in the same format as the standard completion message and 334.Nm 335will exit. 336.Pp 337.Ex -std dd 338.Sh EXAMPLES 339Write an 340.Ox 341floppy image to a floppy disk: 342.Pp 343.Dl # dd if=floppy34.fs of=/dev/rfd0c bs=32k 344.Pp 345Create an ISO-9660 image of a CD-ROM: 346.Pp 347.Dl # dd if=/dev/rcd0c of=disk.iso bs=32k 348.Sh SEE ALSO 349.Xr cp 1 , 350.Xr mt 1 , 351.Xr tr 1 352.Sh STANDARDS 353The 354.Nm 355utility is compliant with the 356.St -p1003.1-2008 357specification. 358.Pp 359The conversions 360.Cm ascii , 361.Cm ebcdic , 362and 363.Cm ibm 364are compliant with the 365.St -xpg4 366specification. 367.Pp 368The 369.Cm files 370operand, 371the conversions 372.Cm oldascii , 373.Cm oldebcdic , 374.Cm oldibm , 375and 376.Cm osync , 377and the size multipliers 378.Sq m 379and 380.Sq w 381are all extensions to those specifications. 382