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