2556 dd should accept M,G,T,... for sizes
[unleashed.git] / usr / src / man / man1m / dd.1m
blobffdedba12f668f9fec597cfb73e204d9e9618b6b
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH DD 1M "Sep 16, 1996"
13 .SH NAME
14 dd \- convert and copy a file
15 .SH SYNOPSIS
16 .LP
17 .nf
18 \fB/usr/bin/dd\fR [\fIoperand=value\fR]...
19 .fi
21 .SH DESCRIPTION
22 .sp
23 .LP
24 The \fBdd\fR utility copies the specified input file to the specified output
25 with possible conversions. The standard input and output are used by default.
26 The input and output block sizes may be specified to take advantage of raw
27 physical I/O. Sizes are specified in bytes; a number may end with \fBk\fR,
28 \fBb\fR, or \fBw\fR to specify multiplication by 1024, 512, or 2, respectively.
29 Numbers may also be separated by \fBx\fR to indicate multiplication.
30 .sp
31 .LP
32 The \fBdd\fR utility reads the input one block at a time, using the specified
33 input block size. \fBdd\fR then processes the block of data actually returned,
34 which could be smaller than the requested block size. \fBdd\fR applies any
35 conversions that have been specified and writes the resulting data to the
36 output in blocks of the specified output block size.
37 .sp
38 .LP
39 \fBcbs\fR is used only if \fBascii\fR, \fBasciib\fR, \fBunblock\fR,
40 \fBebcdic\fR, \fBebcdicb\fR, \fBibm\fR, \fBibmb\fR, or \fBblock\fR conversion
41 is specified. In the first two cases, \fBcbs\fR characters are copied into the
42 conversion buffer, any specified character mapping is done, trailing blanks are
43 trimmed, and a \fBNEWLINE\fR is added before sending the line to output. In the
44 last three cases, characters up to \fBNEWLINE\fR are read into the conversion
45 buffer and blanks are added to make up an output record of size \fBcbs\fR.
46 \fBASCII\fR files are presumed to contain \fBNEWLINE\fR characters. If
47 \fBcbs\fR is unspecified or \fB0\fR, the \fBascii\fR, \fBasciib\fR,
48 \fBebcdic\fR, \fBebcdicb\fR, \fBibm\fR, and \fBibmb\fR options convert the
49 character set without changing the input file's block structure. The
50 \fBunblock\fR and \fBblock\fR options become a simple file copy.
51 .sp
52 .LP
53 After completion, \fBdd\fR reports the number of whole and partial input and
54 output blocks.
55 .SH OPERANDS
56 .sp
57 .LP
58 The following operands are supported:
59 .sp
60 .ne 2
61 .na
62 \fB\fBif=\fR\fIfile\fR\fR
63 .ad
64 .sp .6
65 .RS 4n
66 Specifies the input path. Standard input is the default.
67 .RE
69 .sp
70 .ne 2
71 .na
72 \fB\fBof=\fR\fIfile\fR\fR
73 .ad
74 .sp .6
75 .RS 4n
76 Specifies the output path. Standard output is the default. If the
77 \fBseek=\fR\fBexpr\fR conversion is not also specified, the output file will be
78 truncated before the copy begins, unless \fBconv=notrunc\fR is specified. If
79 \fBseek=\fR\fBexpr\fR is specified, but \fBconv=notrunc\fR is not, the effect
80 of the copy will be to preserve the blocks in the output file over which
81 \fBdd\fR seeks, but no other portion of the output file will be preserved. (If
82 the size of the seek plus the size of the input file is less than the previous
83 size of the output file, the output file is shortened by the copy.)
84 .RE
86 .sp
87 .ne 2
88 .na
89 \fB\fBibs=\fR\fIn\fR\fR
90 .ad
91 .sp .6
92 .RS 4n
93 Specifies the input block size in \fIn\fR bytes (default is \fB512\fR).
94 .RE
96 .sp
97 .ne 2
98 .na
99 \fB\fBobs=\fR\fIn\fR\fR
101 .sp .6
102 .RS 4n
103 Specifies the output block size in \fIn\fR bytes (default is \fB512\fR).
107 .ne 2
109 \fB\fBbs=\fR\fIn\fR\fR
111 .sp .6
112 .RS 4n
113 Sets both input and output block sizes to \fIn\fR bytes, superseding \fBibs=\fR
114 and \fBobs=\fR. If no conversion other than \fBsync\fR,\fB noerror\fR, and
115 \fBnotrunc\fR is specified, each input block is copied to the output as a
116 single block without aggregating short blocks.
120 .ne 2
122 \fB\fBcbs=\fR\fIn\fR\fR
124 .sp .6
125 .RS 4n
126 Specifies the conversion block size for \fBblock\fR and \fBunblock\fR in bytes
127 by \fIn\fR (default is \fB0\fR). If \fBcbs=\fR is omitted or given a value of
128 \fB0\fR, using \fBblock\fR or \fBunblock\fR produces unspecified results.
130 This option is used only if \fBASCII\fR or \fBEBCDIC\fR conversion is
131 specified. For the \fBascii\fR and \fBasciib\fR operands, the input is handled
132 as described for the \fBunblock\fR operand except that characters are converted
133 to \fBASCII\fR before the trailing \fBSPACE\fR characters are deleted. For the
134 \fBebcdic\fR, \fBebcdicb\fR, \fBibm\fR, and \fBibmb\fR operands, the input is
135 handled as described for the \fBblock\fR operand except that the characters are
136 converted to \fBEBCDIC\fR or IBM \fBEBCDIC\fR after the trailing \fBSPACE\fR
137 characters are added.
141 .ne 2
143 \fB\fBfiles=\fR\fIn\fR\fR
145 .sp .6
146 .RS 4n
147 Copies and concatenates \fIn\fR input files before terminating (makes sense
148 only where input is a magnetic tape or similar device).
152 .ne 2
154 \fB\fBskip=\fR\fIn\fR\fR
156 .sp .6
157 .RS 4n
158 Skips \fIn\fR input blocks (using the specified input block size) before
159 starting to copy. On seekable files, the implementation reads the blocks or
160 seeks past them. On non-seekable files, the blocks are read and the data is
161 discarded.
165 .ne 2
167 \fB\fBiseek=\fR\fIn\fR\fR
169 .sp .6
170 .RS 4n
171 Seeks \fIn\fR blocks from beginning of input file before copying (appropriate
172 for disk files, where \fBskip\fR can be incredibly slow).
176 .ne 2
178 \fB\fBoseek=\fR\fIn\fR\fR
180 .sp .6
181 .RS 4n
182 Seeks \fIn\fR blocks from beginning of output file before copying.
186 .ne 2
188 \fB\fBseek=\fR\fIn\fR\fR
190 .sp .6
191 .RS 4n
192 Skips \fIn\fR blocks (using the specified output block size) from beginning of
193 output file before copying. On non-seekable files, existing blocks are read and
194 space from the current end-of-file to the specified offset, if any, is filled
195 with null bytes. On seekable files, the implementation seeks to the specified
196 offset or reads the blocks as described for non-seekable files.
200 .ne 2
202 \fB\fBcount=\fR\fIn\fR\fR
204 .sp .6
205 .RS 4n
206 Copies only \fIn\fR input blocks.
210 .ne 2
212 \fB\fBconv=\fR\fIvalue\fR[\fB,\fR\fIvalue\fR.\|.\|.\|]\fR
214 .sp .6
215 .RS 4n
216 Where \fIvalue\fRs are comma-separated symbols from the following list:
218 .ne 2
220 \fB\fBascii\fR\fR
222 .RS 11n
223 Converts \fBEBCDIC\fR to \fBASCII\fR.
227 .ne 2
229 \fB\fBasciib\fR\fR
231 .RS 11n
232 Converts \fBEBCDIC\fR to \fBASCII\fR using \fBBSD\fR-compatible character
233 translations.
237 .ne 2
239 \fB\fBebcdic\fR\fR
241 .RS 11n
242 Converts \fBASCII\fR to \fBEBCDIC\fR. If converting fixed-length \fBASCII\fR
243 records without NEWLINEs, sets up a pipeline with \fBdd conv=unblock\fR
244 beforehand.
248 .ne 2
250 \fB\fBebcdicb\fR\fR
252 .RS 11n
253 Converts \fBASCII\fR to \fBEBCDIC\fR using \fBBSD\fR-compatible character
254 translations. If converting fixed-length \fBASCII\fR records without
255 \fBNEWLINE\fRs, sets up a pipeline with \fBdd conv=unblock\fR beforehand.
259 .ne 2
261 \fB\fBibm\fR\fR
263 .RS 11n
264 Slightly different map of \fBASCII\fR to \fBEBCDIC\fR. If converting
265 fixed-length \fBASCII\fR records without \fBNEWLINE\fRs, sets up a pipeline
266 with \fBdd conv=unblock\fR beforehand.
270 .ne 2
272 \fB\fBibmb\fR\fR
274 .RS 11n
275 Slightly different map of \fBASCII\fR to \fBEBCDIC\fR using
276 \fBBSD\fR-compatible character translations. If converting fixed-length
277 \fBASCII\fR records without \fBNEWLINE\fRs, sets up a pipeline with \fBdd
278 conv=unblock\fR beforehand.
281 The \fBascii\fR (or \fBasciib\fR), \fBebcdic\fR (or \fBebcdicb\fR), and
282 \fBibm\fR (or \fBibmb\fR) values are mutually exclusive.
284 .ne 2
286 \fB\fBblock\fR\fR
288 .RS 11n
289 Treats the input as a sequence of \fBNEWLINE\fR-terminated or
290 \fBEOF\fR-terminated variable-length records independent of the input block
291 boundaries. Each record is converted to a record with a fixed length specified
292 by the conversion block size. Any \fBNEWLINE\fR character is removed from the
293 input line. \fBSPACE\fR characters are appended to lines that are shorter than
294 their conversion block size to fill the block. Lines that are longer than the
295 conversion block size are truncated to the largest number of characters that
296 will fit into that size. The number of truncated lines is reported.
300 .ne 2
302 \fB\fBunblock\fR\fR
304 .RS 11n
305 Converts fixed-length records to variable length. Reads a number of bytes equal
306 to the conversion block size (or the number of bytes remaining in the input, if
307 less than the conversion block size), delete all trailing \fBSPACE\fR
308 characters, and append a \fBNEWLINE\fR character.
311 The  \fBblock\fR and \fBunblock\fR values are mutually exclusive.
313 .ne 2
315 \fB\fBlcase\fR\fR
317 .RS 9n
318 Maps upper-case characters specified by the \fBLC_CTYPE\fR keyword
319 \fBtolower\fR to the corresponding lower-case character. Characters for which
320 no mapping is specified are not modified by this conversion.
324 .ne 2
326 \fB\fBucase\fR\fR
328 .RS 9n
329 Maps lower-case characters specified by the \fBLC_CTYPE\fR keyword
330 \fBtoupper\fR to the corresponding upper-case character. Characters for which
331 no mapping is specified are not modified by this conversion.
334 The \fBlcase\fR and \fBucase\fR symbols are mutually exclusive.
336 .ne 2
338 \fB\fBswab\fR\fR
340 .RS 11n
341 Swaps every pair of input bytes. If the current input record is an odd number
342 of bytes, the last byte in the input record is ignored.
346 .ne 2
348 \fB\fBnoerror\fR\fR
350 .RS 11n
351 Does not stop processing on an input error. When an input error occurs, a
352 diagnostic message is written on standard error, followed by the current input
353 and output block counts in the same format as used at completion. If the
354 \fBsync\fR conversion is specified, the missing input is replaced with null
355 bytes and processed normally. Otherwise, the input block will be omitted from
356 the output.
360 .ne 2
362 \fB\fBnotrunc\fR\fR
364 .RS 11n
365 Does not truncate the output file. Preserves blocks in the output file not
366 explicitly written by this invocation of \fBdd\fR. (See also the preceding
367 \fBof=\fR\fIfile\fR operand.)
371 .ne 2
373 \fB\fBsync\fR\fR
375 .RS 11n
376 Pads every input block to the size of the \fBibs=\fR buffer, appending null
377 bytes. (If either \fBblock\fR or \fBunblock\fR is also specified, appends
378 \fBSPACE\fR characters, rather than null bytes.)
385 If operands other than \fBconv=\fR are specified more than once, the last
386 specified \fBoperand=\fR\fIvalue\fR is used.
389 For the \fBbs=\fR, \fBcbs=\fR, \fBibs=\fR, and \fBobs=\fR operands, the
390 application must supply an expression specifying a size in bytes. The
391 expression, \fBexpr\fR, can be:
392 .RS +4
395 a positive decimal number
397 .RS +4
400 a positive decimal number followed by \fBk\fR, specifying multiplication by
401 1024
403 .RS +4
406 a positive decimal number followed by \fBM\fR, specifying multiplication by
407 1024*1024
409 .RS +4
412 a positive decimal number followed by \fBG\fR, specifying multiplication by
413 1024*1024*1024
415 .RS +4
418 a positive decimal number followed by \fBT\fR, specifying multiplication by
419 1024*1024*1024*1024
421 .RS +4
424 a positive decimal number followed by \fBP\fR, specifying multiplication by
425 1024*1024*1024*1024*1024
427 .RS +4
430 a positive decimal number followed by \fBE\fR, specifying multiplication by
431 1024*1024*1024*1024*1024*1024
433 .RS +4
436 a positive decimal number followed by \fBZ\fR, specifying multiplication by
437 1024*1024*1024*1024*1024*1024*1024
439 .RS +4
442 a positive decimal number followed by \fBb\fR, specifying multiplication by
445 .RS +4
448 two or more positive decimal numbers (with or without \fBk\fR or \fBb\fR)
449 separated by \fBx\fR, specifying the product of the indicated values.
453 All of the operands will be processed before any input is read.
454 .SH USAGE
457 See \fBlargefile\fR(5) for the description of the behavior of \fBdd\fR when
458 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
459 .SH EXAMPLES
461 \fBExample 1 \fRCopying from one tape drive to another
464 The following example copies from tape drive \fB0\fR to tape drive \fB1\fR,
465 using a common historical device naming convention.
468 .in +2
470 example% \fBdd if=/dev/rmt/0h  of=/dev/rmt/1h\fR
472 .in -2
476 \fBExample 2 \fRStripping the first 10 bytes from standard input
479 The following example strips the first 10 bytes from standard input:
482 .in +2
484 example% \fBdd ibs=10  skip=1\fR
486 .in -2
490 \fBExample 3 \fRReading a tape into an ASCII file
493 This example reads an \fBEBCDIC\fR tape blocked ten 80-byte \fBEBCDIC\fR card
494 images per block into the \fBASCII\fR file \fBx\fR:
497 .in +2
499 example% \fBdd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase\fR
501 .in -2
505 \fBExample 4 \fRUsing conv=sync to write to tape
508 The following example uses \fBconv=sync\fR when writing to a tape:
511 .in +2
513 example% \fBtar cvf - . | compress | dd obs=1024k of=/dev/rmt/0 conv=sync\fR
515 .in -2
518 .SH ENVIRONMENT VARIABLES
521 See \fBenviron\fR(5) for descriptions of the following environment variables
522 that affect the execution of \fBdd\fR: \fBLANG\fR, \fBLC_ALL\fR,
523 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
524 .SH EXIT STATUS
527 The following exit values are returned:
529 .ne 2
531 \fB\fB0\fR\fR
533 .RS 6n
534 The input file was copied successfully.
538 .ne 2
540 \fB\fB>0\fR\fR
542 .RS 6n
543 An error occurred.
548 If an input error is detected and the \fBnoerror\fR conversion has not been
549 specified, any partial output block will be written to the output file, a
550 diagnostic message will be written, and the copy operation will be
551 discontinued. If some other error is detected, a diagnostic message will be
552 written and the copy operation will be discontinued.
553 .SH ATTRIBUTES
556 See \fBattributes\fR(5) for descriptions of the following attributes:
561 box;
562 c | c
563 l | l .
564 ATTRIBUTE TYPE  ATTRIBUTE VALUE
566 Interface Stability     Standard
569 .SH SEE ALSO
572 \fBcp\fR(1), \fBsed\fR(1), \fBtr\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
573 \fBlargefile\fR(5), \fBstandards\fR(5)
574 .SH DIAGNOSTICS
576 .ne 2
578 \fB\fBf+p records in(out)\fR\fR
580 .RS 23n
581 numbers of full and partial blocks read(written)
584 .SH NOTES
587 Do not use \fBdd\fR to copy files between file systems having different block
588 sizes.
591 Using a  blocked device to copy a file will result in extra nulls being added
592 to the file to pad the final block to the block boundary.
595 When  \fBdd\fR reads from a pipe, using the  \fBibs=X\fR and  \fBobs=Y\fR
596 operands, the output will always be blocked in chunks of size Y. When
597 \fBbs=Z\fR is used, the output blocks will be whatever was available to be read
598 from the pipe at the time.
601 When using \fBdd\fR to copy files to a tape device, the file size must be a
602 multiple of the device sector size (for example, 512 Kbyte).  To  copy files of
603 arbitrary size to a tape device, use  \fBtar\fR(1) or  \fBcpio\fR(1).
606 For \fBSIGINT\fR, \fBdd\fR writes status information to standard error before
607 exiting. It takes the standard action for all other signals.