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