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$ 37.\" 38.Dd January 13, 1994 39.Dt DD 1 40.Os 41.Sh NAME 42.Nm dd 43.Nd convert and copy a file 44.Sh SYNOPSIS 45.Nm dd 46.Op operands ... 47.Sh DESCRIPTION 48The 49.Nm 50utility copies the standard input to the standard output. 51Input data is read and written in 512-byte blocks. 52If input reads are short, input from multiple reads are aggregated 53to form the output block. 54When finished, 55.Nm 56displays the number of complete and partial input and output blocks 57and truncated input records to the standard error output. 58.Pp 59The following operands are available: 60.Bl -tag -width of=file 61.It Cm bs= Ns Ar n 62Set both input and output block size to 63.Va n 64bytes, superseding the 65.Cm ibs 66and 67.Cm obs 68operands. 69If no conversion values other than 70.Cm noerror , 71.Cm notrunc 72or 73.Cm sync 74are specified, then each input block is copied to the output as a 75single block without any aggregation of short blocks. 76.It Cm cbs= Ns Ar n 77Set the conversion record size to 78.Va n 79bytes. 80The conversion record size is required by the record oriented conversion 81values. 82.It Cm count= Ns Ar n 83Copy only 84.Va n 85input blocks. 86.It Cm files= Ns Ar n 87Copy 88.Va n 89input files before terminating. 90This operand is only applicable when the input device is a tape. 91.It Cm ibs= Ns Ar n 92Set the input block size to 93.Va n 94bytes instead of the default 512. 95.It Cm if= Ns Ar file 96Read input from 97.Ar file 98instead of the standard input. 99.It Cm iseek= Ns Ar n 100Seek on the input file 101.Va n 102blocks. This is synonymous with 103.Cm skip= Ns Ar n . 104.It Cm obs= Ns Ar n 105Set the output block size to 106.Va n 107bytes instead of the default 512. 108.It Cm of= Ns Ar file 109Write output to 110.Ar file 111instead of the standard output. 112Any regular output file is truncated unless the 113.Cm notrunc 114conversion value is specified. 115If an initial portion of the output file is seeked past (see the 116.Cm oseek 117operand), 118the output file is truncated at that point. 119.It Cm oseek= Ns Ar n 120Seek on the output file 121.Va n 122blocks. This is synonymous with 123.Cm seek= Ns Ar n . 124.It Cm seek= Ns Ar n 125Seek 126.Va n 127blocks from the beginning of the output before copying. 128On non-tape devices, an 129.Xr lseek 2 130operation is used. 131Otherwise, existing blocks are read and the data discarded. 132If the user does not have read permission for the tape, it is positioned 133using the tape 134.Xr ioctl 2 135function calls. 136If the seek operation is past the end of file, space from the current 137end of file to the specified offset is filled with blocks of 138.Tn NUL 139bytes. 140.It Cm skip= Ns Ar n 141Skip 142.Va n 143blocks from the beginning of the input before copying. 144On input which supports seeks, an 145.Xr lseek 2 146operation is used. 147Otherwise, input data is read and discarded. 148For pipes, the correct number of bytes is read. 149For all other devices, the correct number of blocks is read without 150distinguishing between a partial or complete block being read. 151.It Xo 152.Cm conv= 153.Ns Cm value Ns Op \&, Cm value \&... 154.Xc 155Where 156.Cm value 157is one of the symbols from the following list. 158.Bl -tag -width 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 System V. 178The value 179.Cm oldascii 180specifies the one used in historic 181.Tn AT&T 182and pre-4.3BSD-reno systems. 183.It Cm block 184Treats the input as a sequence of newline or end-of-file terminated variable 185length records independent of input and output block boundaries. 186Any trailing newline character is discarded. 187Each input record is converted to a fixed length output record where the 188length is specified by the 189.Cm cbs 190operand. 191Input records shorter than the conversion record size are padded with spaces. 192Input records longer than the conversion record size are truncated. 193The number of truncated input records, if any, are reported to the standard 194error output at the completion of the copy. 195.It Cm ebcdic , ibm , oldebcdic , oldibm 196The same as the 197.Cm block 198value except that characters are translated from 199.Tn ASCII 200to 201.Tn EBCDIC 202after the 203records are converted. 204(These values imply 205.Cm block 206if the operand 207.Cm cbs 208is also specified.) 209There are four conversion maps for 210.Tn EBCDIC . 211The value 212.Cm ebcdic 213specifies the recommended one which is compatible with 214.At V . 215The value 216.Cm ibm 217is a slightly different mapping, which is compatible with the 218.At V 219.Cm ibm 220value. 221The values 222.Cm oldebcdic 223and 224.Cm oldibm 225are maps used in historic 226.Tn AT&T 227and pre-4.3BSD-reno systems. 228.It Cm lcase 229Transform uppercase characters into lowercase characters. 230.It Cm noerror 231Do not stop processing on an input error. 232When an input error occurs, a diagnostic message followed by the current 233input and output block counts will be written to the standard error output 234in the same format as the standard completion message. 235If the 236.Cm sync 237conversion is also specified, any missing input data will be replaced 238with 239.Tn NUL 240bytes (or with spaces if a block oriented conversion value was 241specified) and processed as a normal input buffer. 242If the 243.Cm sync 244conversion is not specified, the input block is omitted from the output. 245On input files which are not tapes or pipes, the file offset 246will be positioned past the block in which the error occurred using 247.Xr lseek 2 . 248.It Cm notrunc 249Do not truncate the output file. 250This will preserve any blocks in the output file not explicitly written 251by 252.Nm Ns . 253The 254.Cm notrunc 255value is not supported for tapes. 256.It Cm osync 257Pad the final output block to the full output block size. 258If the input file is not a multiple of the output block size 259after conversion, this conversion forces the final output block 260to be the same size as preceding blocks for use on devices that require 261regularly sized blocks to be written. 262This option is incompatible with use of the 263.Cm bs= Ns Ar n 264block size specification. 265.It Cm sparse 266If one or more output blocks would consist solely of 267.Tn NUL 268bytes, try to seek the output file by the required space instead of 269filling them with 270.Tn NULs , 271resulting in a sparse file. 272.It Cm swab 273Swap every pair of input bytes. 274If an input buffer has an odd number of bytes, the last byte will be 275ignored during swapping. 276.It Cm sync 277Pad every input block to the input buffer size. 278Spaces are used for pad bytes if a block oriented conversion value is 279specified, otherwise 280.Tn NUL 281bytes are used. 282.It Cm ucase 283Transform lowercase characters into uppercase characters. 284.It Cm unblock 285Treats the input as a sequence of fixed length records independent of input 286and output block boundaries. 287The length of the input records is specified by the 288.Cm cbs 289operand. 290Any trailing space characters are discarded and a newline character is 291appended. 292.El 293.El 294.Pp 295Where sizes are specified, a decimal, octal, or hexadecimal number of 296bytes is expected. 297If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'', the 298number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G) 299or the number of bytes in an integer, respectively. 300Two or more numbers may be separated by an ``x'' to indicate a product. 301.Pp 302When finished, 303.Nm 304displays the number of complete and partial input and output blocks, 305truncated input records and odd-length byte-swapping blocks to the 306standard error output. 307A partial input block is one where less than the input block size 308was read. 309A partial output block is one where less than the output block size 310was written. 311Partial output blocks to tape devices are considered fatal errors. 312Otherwise, the rest of the block will be written. 313Partial output blocks to character devices will produce a warning message. 314A truncated input block is one where a variable length record oriented 315conversion value was specified and the input line was too long to 316fit in the conversion record or was not newline terminated. 317.Pp 318Normally, data resulting from input or conversion or both are aggregated 319into output blocks of the specified size. 320After the end of input is reached, any remaining output is written as 321a block. 322This means that the final output block may be shorter than the output 323block size. 324.Pp 325If 326.Nm 327receives a 328.Dv SIGINFO 329(see the ``status'' argument for 330.Xr stty 1 ) 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. 334If 335.Nm 336receives a 337.Dv SIGINT 338signal, the current input and output block counts will 339be written to the standard error output 340in the same format as the standard completion message and 341.Nm 342will exit. 343.Sh DIAGNOSTICS 344The 345.Nm 346utility exits 0 on success or >0 if an error occurs. 347.Sh SEE ALSO 348.Xr cp 1 , 349.Xr mt 1 , 350.Xr tr 1 351.Sh STANDARDS 352The 353.Nm 354utility is expected to be a superset of the 355.St -p1003.2 356standard. 357The 358.Cm files 359operand and the 360.Cm ascii , 361.Cm ebcdic , 362.Cm ibm , 363.Cm oldascii , 364.Cm oldebcdic 365and 366.Cm oldibm 367values are extensions to the 368.Tn POSIX 369standard. 370