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