1dd(1M)                  System Administration Commands                  dd(1M)
2
3
4

NAME

6       dd - convert and copy a file
7

SYNOPSIS

9       /usr/bin/dd [operand=value]...
10
11

DESCRIPTION

13       The  dd utility copies the specified input file to the specified output
14       with possible conversions. The standard input and output  are  used  by
15       default.  The  input  and  output  block sizes may be specified to take
16       advantage of raw physical I/O. Sizes are specified in bytes;  a  number
17       may  end  with k, b, or w to specify multiplication by 1024, 512, or 2,
18       respectively. Numbers may also be separated by x to indicate  multipli‐
19       cation.
20
21
22       The dd utility reads the input one block at a time, using the specified
23       input block  size.  dd  then  processes  the  block  of  data  actually
24       returned,  which  could  be  smaller  than the requested block size. dd
25       applies any conversions that have been specified and writes the result‐
26       ing data to the output in blocks of the specified output block size.
27
28
29       cbs is used only if ascii, asciib, unblock, ebcdic, ebcdicb, ibm, ibmb,
30       or block conversion is specified. In the first two cases,  cbs  charac‐
31       ters  are  copied  into  the conversion buffer, any specified character
32       mapping is done, trailing blanks are trimmed, and a  NEWLINE  is  added
33       before  sending the line to output. In the last three cases, characters
34       up to NEWLINE are read into the conversion buffer and blanks are  added
35       to  make  up  an output record of size cbs. ASCII files are presumed to
36       contain NEWLINE characters. If cbs is  unspecified  or  0,  the  ascii,
37       asciib,  ebcdic,  ebcdicb,  ibm, and ibmb options convert the character
38       set without changing the input file's block structure. The unblock  and
39       block options become a simple file copy.
40
41
42       After  completion, dd reports the number of whole and partial input and
43       output blocks.
44

OPERANDS

46       The following operands are supported:
47
48       if=file
49
50           Specifies the input path. Standard input is the default.
51
52
53       of=file
54
55           Specifies the output path. Standard output is the default.  If  the
56           seek=expr conversion is not also specified, the output file will be
57           truncated before the copy begins, unless conv=notrunc is specified.
58           If  seek=expr  is specified, but conv=notrunc is not, the effect of
59           the copy will be to preserve the blocks in  the  output  file  over
60           which  dd  seeks,  but  no other portion of the output file will be
61           preserved. (If the size of the seek plus the size of the input file
62           is  less than the previous size of the output file, the output file
63           is shortened by the copy.)
64
65
66       ibs=n
67
68           Specifies the input block size in n bytes (default is 512).
69
70
71       obs=n
72
73           Specifies the output block size in n bytes (default is 512).
74
75
76       bs=n
77
78           Sets both input and output block sizes to n bytes, superseding ibs=
79           and obs=. If no conversion other than sync, noerror, and notrunc is
80           specified, each input block is copied to the  output  as  a  single
81           block without aggregating short blocks.
82
83
84       cbs=n
85
86           Specifies  the conversion block size for block and unblock in bytes
87           by n (default is 0). If cbs= is omitted or  given  a  value  of  0,
88           using block or unblock produces unspecified results.
89
90           This  option  is  used only if ASCII or EBCDIC conversion is speci‐
91           fied. For the ascii and asciib operands, the input  is  handled  as
92           described  for  the unblock operand except that characters are con‐
93           verted to ASCII before the trailing SPACE characters  are  deleted.
94           For  the ebcdic, ebcdicb, ibm, and ibmb operands, the input is han‐
95           dled as described for the block operand except that the  characters
96           are  converted  to  EBCDIC  or  IBM EBCDIC after the trailing SPACE
97           characters are added.
98
99
100       files=n
101
102           Copies and concatenates n input  files  before  terminating  (makes
103           sense only where input is a magnetic tape or similar device).
104
105
106       skip=n
107
108           Skips  n input blocks (using the specified input block size) before
109           starting to copy. On seekable files, the implementation  reads  the
110           blocks  or  seeks  past them. On non-seekable files, the blocks are
111           read and the data is discarded.
112
113
114       iseek=n
115
116           Seeks n blocks from beginning of input file before copying  (appro‐
117           priate for disk files, where skip can be incredibly slow).
118
119
120       oseek=n
121
122           Seeks n blocks from beginning of output file before copying.
123
124
125       seek=n
126
127           Skips  n blocks (using the specified output block size) from begin‐
128           ning of output file before copying. On non-seekable files, existing
129           blocks are read and space from the current end-of-file to the spec‐
130           ified offset, if any, is filled with null bytes. On seekable files,
131           the  implementation  seeks  to  the  specified  offset or reads the
132           blocks as described for non-seekable files.
133
134
135       count=n
136
137           Copies only n input blocks.
138
139
140       conv=value[,value...]
141
142           Where values are comma-separated symbols from the following list:
143
144           ascii      Converts EBCDIC to ASCII.
145
146
147           asciib     Converts EBCDIC to ASCII using BSD-compatible  character
148                      translations.
149
150
151           ebcdic     Converts  ASCII  to  EBCDIC.  If converting fixed-length
152                      ASCII records without NEWLINEs, sets up a pipeline  with
153                      dd conv=unblock beforehand.
154
155
156           ebcdicb    Converts  ASCII to EBCDIC using BSD-compatible character
157                      translations. If converting fixed-length  ASCII  records
158                      without   NEWLINEs,   sets   up   a   pipeline  with  dd
159                      conv=unblock beforehand.
160
161
162           ibm        Slightly different map of ASCII to EBCDIC. If converting
163                      fixed-length  ASCII  records without NEWLINEs, sets up a
164                      pipeline with dd conv=unblock beforehand.
165
166
167           ibmb       Slightly different map of ASCII to EBCDIC using BSD-com‐
168                      patible  character  translations.  If  converting fixed-
169                      length ASCII records without NEWLINEs, sets up  a  pipe‐
170                      line with dd conv=unblock beforehand.
171
172           The  ascii (or asciib), ebcdic (or ebcdicb), and ibm (or ibmb) val‐
173           ues are mutually exclusive.
174
175           block      Treats the input as a sequence of NEWLINE-terminated  or
176                      EOF-terminated  variable-length  records  independent of
177                      the input block boundaries. Each record is converted  to
178                      a record with a fixed length specified by the conversion
179                      block size. Any NEWLINE character is  removed  from  the
180                      input  line. SPACE characters are appended to lines that
181                      are shorter than their conversion block size to fill the
182                      block.  Lines  that are longer than the conversion block
183                      size are truncated to the largest number  of  characters
184                      that  will  fit  into that size. The number of truncated
185                      lines is reported.
186
187
188           unblock    Converts fixed-length records to variable length.  Reads
189                      a number of bytes equal to the conversion block size (or
190                      the number of bytes remaining in the input, if less than
191                      the  conversion  block  size), delete all trailing SPACE
192                      characters, and append a NEWLINE character.
193
194           The  block and unblock values are mutually exclusive.
195
196           lcase    Maps upper-case characters specified by the LC_CTYPE  key‐
197                    word  tolower  to  the corresponding lower-case character.
198                    Characters for which no mapping is specified are not modi‐
199                    fied by this conversion.
200
201
202           ucase    Maps  lower-case characters specified by the LC_CTYPE key‐
203                    word toupper to the  corresponding  upper-case  character.
204                    Characters for which no mapping is specified are not modi‐
205                    fied by this conversion.
206
207           The lcase and ucase symbols are mutually exclusive.
208
209           swab       Swaps every pair of input bytes. If  the  current  input
210                      record  is  an odd number of bytes, the last byte in the
211                      input record is ignored.
212
213
214           noerror    Does not stop processing on  an  input  error.  When  an
215                      input  error  occurs, a diagnostic message is written on
216                      standard error, followed by the current input and output
217                      block  counts  in the same format as used at completion.
218                      If the sync conversion is specified, the  missing  input
219                      is replaced with null bytes and processed normally. Oth‐
220                      erwise, the input block will be omitted from the output.
221
222
223           notrunc    Does not truncate the output file. Preserves  blocks  in
224                      the  output  file not explicitly written by this invoca‐
225                      tion of dd. (See also the preceding of=file operand.)
226
227
228           sync       Pads every input block to the size of the  ibs=  buffer,
229                      appending  null  bytes.  (If  either block or unblock is
230                      also specified, appends SPACE  characters,  rather  than
231                      null bytes.)
232
233
234
235
236       If  operands  other  than  conv= are specified more than once, the last
237       specified operand=value is used.
238
239
240       For the bs=, cbs=, ibs=, and obs= operands, the application must supply
241       an expression specifying a size in bytes. The expression, expr, can be:
242
243           1.     a positive decimal number
244
245           2.     a  positive  decimal number followed by k, specifying multi‐
246                  plication by 1024
247
248           3.     a positive decimal number followed by b,  specifying  multi‐
249                  plication by 512
250
251           4.     two  or  more positive decimal numbers (with or without k or
252                  b) separated by x, specifying the product of  the  indicated
253                  values.
254
255
256       All of the operands will be processed before any input is read.
257

USAGE

259       See largefile(5) for the description of the behavior of dd when encoun‐
260       tering files greater than or equal to 2 Gbyte ( 2^31 bytes).
261

EXAMPLES

263       Example 1 Copying from one tape drive to another
264
265
266       The following example copies from tape drive 0 to tape drive 1, using a
267       common historical device naming convention.
268
269
270         example% dd if=/dev/rmt/0h  of=/dev/rmt/1h
271
272
273
274       Example 2 Stripping the first 10 bytes from standard input
275
276
277       The following example strips the first 10 bytes from standard input:
278
279
280         example% dd ibs=10  skip=1
281
282
283
284       Example 3 Reading a tape into an ASCII file
285
286
287       This  example  reads  an  EBCDIC  tape  blocked ten 80-byte EBCDIC card
288       images per block into the ASCII file x:
289
290
291         example% dd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase
292
293
294
295       Example 4 Using conv=sync to write to tape
296
297
298       The following example uses conv=sync when writing to a tape:
299
300
301         example% tar cvf - . | compress | dd obs=1024k of=/dev/rmt/0 conv=sync
302
303
304

ENVIRONMENT VARIABLES

306       See environ(5) for descriptions of the following environment  variables
307       that  affect  the execution of dd: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
308       and NLSPATH.
309

EXIT STATUS

311       The following exit values are returned:
312
313       0     The input file was copied successfully.
314
315
316       >0    An error occurred.
317
318
319
320       If an input error is detected and the noerror conversion has  not  been
321       specified, any partial output block will be written to the output file,
322       a diagnostic message will be written, and the copy  operation  will  be
323       discontinued.  If  some  other  error is detected, a diagnostic message
324       will be written and the copy operation will be discontinued.
325

ATTRIBUTES

327       See attributes(5) for descriptions of the following attributes:
328
329
330
331
332       ┌─────────────────────────────┬─────────────────────────────┐
333       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
334       ├─────────────────────────────┼─────────────────────────────┤
335       │Availability                 │SUNWcsu                      │
336       ├─────────────────────────────┼─────────────────────────────┤
337       │Interface Stability          │Standard                     │
338       └─────────────────────────────┴─────────────────────────────┘
339

SEE ALSO

341       cp(1), sed(1), tr(1), attributes(5),  environ(5),  largefile(5),  stan‐
342       dards(5)
343

DIAGNOSTICS

345       f+p records in(out)    numbers of full and partial blocks read(written)
346
347

NOTES

349       Do not use dd to copy files between file systems having different block
350       sizes.
351
352
353       Using a  blocked device to copy a file will result in extra nulls being
354       added to the file to pad the final block to the block boundary.
355
356
357       When   dd  reads from a pipe, using the  ibs=X and  obs=Y operands, the
358       output will always be blocked in chunks of size Y. When  bs=Z is  used,
359       the  output  blocks  will be whatever was available to be read from the
360       pipe at the time.
361
362
363       When using dd to copy files to a tape device, the file size must  be  a
364       multiple  of the device sector size (for example, 512 Kbyte).  To  copy
365       files of arbitrary size to a tape device, use  tar(1) or  cpio(1).
366
367
368       For SIGINT, dd writes status information to standard error before exit‐
369       ing. It takes the standard action for all other signals.
370
371
372
373SunOS 5.11                        16 Sep 1996                           dd(1M)
Impressum