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