1 DD(1M)                       Maintenance Commands                       DD(1M)
   2 
   3 
   4 
   5 NAME
   6        dd - convert and copy a file
   7 
   8 SYNOPSIS
   9        /usr/bin/dd [operand=value]...
  10 
  11 
  12 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
  19        multiplication.
  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
  26        resulting data to the output in blocks of the specified output block
  27        size.
  28 
  29 
  30        cbs is used only if ascii, asciib, unblock, ebcdic, ebcdicb, ibm, ibmb,
  31        or block conversion is specified. In the first two cases, cbs
  32        characters are copied into the conversion buffer, any specified
  33        character mapping is done, trailing blanks are trimmed, and a NEWLINE
  34        is added before sending the line to output. In the last three cases,
  35        characters up to NEWLINE are read into the conversion buffer and blanks
  36        are added to make up an output record of size cbs.  ASCII files are
  37        presumed to contain NEWLINE characters. If cbs is unspecified or 0, the
  38        ascii, asciib, ebcdic, ebcdicb, ibm, and ibmb options convert the
  39        character set without changing the input file's block structure. The
  40        unblock and block options become a simple file copy.
  41 
  42 
  43        After completion, dd reports the number of whole and partial input and
  44        output blocks.
  45 
  46 OPERANDS
  47        The following operands are supported:
  48 
  49        if=file
  50 
  51            Specifies the input path. Standard input is the default.
  52 
  53 
  54        of=file
  55 
  56            Specifies the output path. Standard output is the default. If the
  57            seek=expr conversion is not also specified, the output file will be
  58            truncated before the copy begins, unless conv=notrunc is specified.
  59            If seek=expr is specified, but conv=notrunc is not, the effect of
  60            the copy will be to preserve the blocks in the output file over
  61            which dd seeks, but no other portion of the output file will be
  62            preserved. (If the size of the seek plus the size of the input file
  63            is less than the previous size of the output file, the output file
  64            is shortened by the copy.)
  65 
  66 
  67        ibs=n
  68 
  69            Specifies the input block size in n bytes (default is 512).
  70 
  71 
  72        obs=n
  73 
  74            Specifies the output block size in n bytes (default is 512).
  75 
  76 
  77        bs=n
  78 
  79            Sets both input and output block sizes to n bytes, superseding ibs=
  80            and obs=. If no conversion other than sync, noerror, and notrunc is
  81            specified, each input block is copied to the output as a single
  82            block without aggregating short blocks.
  83 
  84 
  85        cbs=n
  86 
  87            Specifies the conversion block size for block and unblock in bytes
  88            by n (default is 0). If cbs= is omitted or given a value of 0,
  89            using block or unblock produces unspecified results.
  90 
  91            This option is used only if ASCII or EBCDIC conversion is
  92            specified. For the ascii and asciib operands, the input is handled
  93            as described for the unblock operand except that characters are
  94            converted to ASCII before the trailing SPACE characters are
  95            deleted. For the ebcdic, ebcdicb, ibm, and ibmb operands, the input
  96            is handled as described for the block operand except that the
  97            characters are converted to EBCDIC or IBM EBCDIC after the trailing
  98            SPACE characters are added.
  99 
 100 
 101        files=n
 102 
 103            Copies and concatenates n input files before terminating (makes
 104            sense only where input is a magnetic tape or similar device).
 105 
 106 
 107        skip=n
 108 
 109            Skips n input blocks (using the specified input block size) before
 110            starting to copy. On seekable files, the implementation reads the
 111            blocks or seeks past them. On non-seekable files, the blocks are
 112            read and the data is discarded.
 113 
 114 
 115        iseek=n
 116 
 117            Seeks n blocks from beginning of input file before copying
 118            (appropriate for disk files, where skip can be incredibly slow).
 119 
 120 
 121        oseek=n
 122 
 123            Seeks n blocks from beginning of output file before copying.
 124 
 125 
 126        seek=n
 127 
 128            Skips n blocks (using the specified output block size) from
 129            beginning of output file before copying. On non-seekable files,
 130            existing blocks are read and space from the current end-of-file to
 131            the specified offset, if any, is filled with null bytes. On
 132            seekable files, the implementation seeks to the specified offset or
 133            reads the blocks as described for non-seekable files.
 134 
 135 
 136        ostride=n
 137 
 138            Writes every nth block (using the specified output block size) when
 139            writing output.  Skips n - 1 blocks after writing each record.
 140 
 141 
 142        istride=n
 143 
 144            Reads every nth block (using the specified input block size) when
 145            reading input.  Skips n - 1 blocks after reading each record.
 146 
 147 
 148        stride=n
 149 
 150            Reads every nth block (using the specified input block size) when
 151            reading input.  Skips n - 1 blocks after reading each record.  Also
 152            writes every nth block (using the specified output block size) when
 153            writing output.  Skips n - 1 blocks after writing each record.
 154 
 155 
 156        count=n
 157 
 158            Copies only n input blocks.
 159 
 160 
 161        conv=value[,value...]
 162 
 163            Where values are comma-separated symbols from the following list:
 164 
 165            ascii
 166                       Converts EBCDIC to ASCII.
 167 
 168 
 169            asciib
 170                       Converts EBCDIC to ASCII using BSD-compatible character
 171                       translations.
 172 
 173 
 174            ebcdic
 175                       Converts ASCII to EBCDIC. If converting fixed-length
 176                       ASCII records without NEWLINEs, sets up a pipeline with
 177                       dd conv=unblock beforehand.
 178 
 179 
 180            ebcdicb
 181                       Converts ASCII to EBCDIC using BSD-compatible character
 182                       translations. If converting fixed-length ASCII records
 183                       without NEWLINEs, sets up a pipeline with dd
 184                       conv=unblock beforehand.
 185 
 186 
 187            ibm
 188                       Slightly different map of ASCII to EBCDIC. If converting
 189                       fixed-length ASCII records without NEWLINEs, sets up a
 190                       pipeline with dd conv=unblock beforehand.
 191 
 192 
 193            ibmb
 194                       Slightly different map of ASCII to EBCDIC using
 195                       BSD-compatible character translations. If converting
 196                       fixed-length ASCII records without NEWLINEs, sets up a
 197                       pipeline with dd conv=unblock beforehand.
 198 
 199            The ascii (or asciib), ebcdic (or ebcdicb), and ibm (or ibmb)
 200            values are mutually exclusive.
 201 
 202            block
 203                       Treats the input as a sequence of NEWLINE-terminated or
 204                       EOF-terminated variable-length records independent of
 205                       the input block boundaries. Each record is converted to
 206                       a record with a fixed length specified by the conversion
 207                       block size. Any NEWLINE character is removed from the
 208                       input line. SPACE characters are appended to lines that
 209                       are shorter than their conversion block size to fill the
 210                       block. Lines that are longer than the conversion block
 211                       size are truncated to the largest number of characters
 212                       that will fit into that size. The number of truncated
 213                       lines is reported.
 214 
 215 
 216            unblock
 217                       Converts fixed-length records to variable length. Reads
 218                       a number of bytes equal to the conversion block size (or
 219                       the number of bytes remaining in the input, if less than
 220                       the conversion block size), delete all trailing SPACE
 221                       characters, and append a NEWLINE character.
 222 
 223            The  block and unblock values are mutually exclusive.
 224 
 225            lcase
 226                     Maps upper-case characters specified by the LC_CTYPE
 227                     keyword tolower to the corresponding lower-case character.
 228                     Characters for which no mapping is specified are not
 229                     modified by this conversion.
 230 
 231 
 232            ucase
 233                     Maps lower-case characters specified by the LC_CTYPE
 234                     keyword toupper to the corresponding upper-case character.
 235                     Characters for which no mapping is specified are not
 236                     modified by this conversion.
 237 
 238            The lcase and ucase symbols are mutually exclusive.
 239 
 240            swab
 241                       Swaps every pair of input bytes. If the current input
 242                       record is an odd number of bytes, the last byte in the
 243                       input record is ignored.
 244 
 245 
 246            noerror
 247                       Does not stop processing on an input error. When an
 248                       input error occurs, a diagnostic message is written on
 249                       standard error, followed by the current input and output
 250                       block counts in the same format as used at completion.
 251                       If the sync conversion is specified, the missing input
 252                       is replaced with null bytes and processed normally.
 253                       Otherwise, the input block will be omitted from the
 254                       output.
 255 
 256 
 257            notrunc
 258                       Does not truncate the output file. Preserves blocks in
 259                       the output file not explicitly written by this
 260                       invocation of dd. (See also the preceding of=file
 261                       operand.)
 262 
 263 
 264            sync
 265                       Pads every input block to the size of the ibs= buffer,
 266                       appending null bytes. (If either block or unblock is
 267                       also specified, appends SPACE characters, rather than
 268                       null bytes.)
 269 
 270 
 271            oflag=value[,value...]
 272 
 273            Where values are comma-separated symbols from the following list
 274            which affect the behavior of writing the output file:
 275 
 276            dsync
 277                       The output file is opened with the O_DSYNC flag set. All
 278                       data writes will be synchronous. For more information on
 279                       O_DSYNC see fcntl.h(3HEAD).
 280 
 281 
 282            sync
 283                       The output file is opened with the O_SYNC flag set. All
 284                       data and metadata writes will be synchronous. For more
 285                       information on O_SYNC see fcntl.h(3HEAD).
 286 
 287 
 288 
 289            If operands other than conv= and oflag= are specified more than
 290            once, the last specified operand=value is used.
 291 
 292 
 293            For the bs=, cbs=, ibs=, and obs= operands, the application must
 294            supply an expression specifying a size in bytes. The expression,
 295            expr, can be:
 296 
 297                1.     a positive decimal number
 298 
 299                2.     a positive decimal number followed by k, specifying
 300                       multiplication by 1024
 301 
 302                3.     a positive decimal number followed by M, specifying
 303                       multiplication by 1024*1024
 304 
 305                4.     a positive decimal number followed by G, specifying
 306                       multiplication by 1024*1024*1024
 307 
 308                5.     a positive decimal number followed by T, specifying
 309                       multiplication by 1024*1024*1024*1024
 310 
 311                6.     a positive decimal number followed by P, specifying
 312                       multiplication by 1024*1024*1024*1024*1024
 313 
 314                7.     a positive decimal number followed by E, specifying
 315                       multiplication by 1024*1024*1024*1024*1024*1024
 316 
 317                8.     a positive decimal number followed by Z, specifying
 318                       multiplication by 1024*1024*1024*1024*1024*1024*1024
 319 
 320                9.     a positive decimal number followed by b, specifying
 321                       multiplication by 512
 322 
 323                10.    two or more positive decimal numbers (with or without k
 324                       or b) separated by x, specifying the product of the
 325                       indicated values.
 326 
 327 
 328            All of the operands will be processed before any input is read.
 329 
 330 SIGNALS
 331        When dd receives either SIGINFO or SIGUSR1, dd will emit the current
 332        input and output block counts, total bytes written, total time elapsed,
 333        and the number of bytes per second to standard error. This is the same
 334        information format that dd emits when it successfully completes. Users
 335        may send SIGINFO via their terminal. The default character is ^T, see
 336        stty(1) for more information.
 337 
 338 
 339        For SIGINT, dd writes status information to standard error before
 340        exiting. dd takes the standard action for all other signals.
 341 
 342 
 343 USAGE
 344        See largefile(5) for the description of the behavior of dd when
 345        encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 346 
 347 EXAMPLES
 348        Example 1 Copying from one tape drive to another
 349 
 350 
 351        The following example copies from tape drive 0 to tape drive 1, using a
 352        common historical device naming convention.
 353 
 354 
 355          example% dd if=/dev/rmt/0h  of=/dev/rmt/1h
 356 
 357 
 358 
 359        Example 2 Stripping the first 10 bytes from standard input
 360 
 361 
 362        The following example strips the first 10 bytes from standard input:
 363 
 364 
 365          example% dd ibs=10  skip=1
 366 
 367 
 368 
 369        Example 3 Reading a tape into an ASCII file
 370 
 371 
 372        This example reads an EBCDIC tape blocked ten 80-byte EBCDIC card
 373        images per block into the ASCII file x:
 374 
 375 
 376          example% dd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase
 377 
 378 
 379 
 380        Example 4 Using conv=sync to write to tape
 381 
 382 
 383        The following example uses conv=sync when writing to a tape:
 384 
 385 
 386          example% tar cvf - . | compress | dd obs=1024k of=/dev/rmt/0 conv=sync
 387 
 388 
 389 
 390 ENVIRONMENT VARIABLES
 391        See environ(5) for descriptions of the following environment variables
 392        that affect the execution of dd: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
 393        and NLSPATH.
 394 
 395 EXIT STATUS
 396        The following exit values are returned:
 397 
 398        0
 399              The input file was copied successfully.
 400 
 401 
 402        >0
 403              An error occurred.
 404 
 405 
 406 
 407        If an input error is detected and the noerror conversion has not been
 408        specified, any partial output block will be written to the output file,
 409        a diagnostic message will be written, and the copy operation will be
 410        discontinued. If some other error is detected, a diagnostic message
 411        will be written and the copy operation will be discontinued.
 412 
 413 ATTRIBUTES
 414        See attributes(5) for descriptions of the following attributes:
 415 
 416 
 417 
 418 
 419        +--------------------+-----------------+
 420        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 421        +--------------------+-----------------+
 422        |Interface Stability | Standard        |
 423        +--------------------+-----------------+
 424 
 425 SEE ALSO
 426        cp(1), sed(1), tr(1), fcntl.h(3HEAD), attributes(5), environ(5),
 427        largefile(5), standards(5)
 428 
 429 DIAGNOSTICS
 430        f+p records in(out)
 431                               numbers of full and partial blocks read(written)
 432 
 433 
 434 NOTES
 435        Do not use dd to copy files between file systems having different block
 436        sizes.
 437 
 438 
 439        Using a  blocked device to copy a file will result in extra nulls being
 440        added to the file to pad the final block to the block boundary.
 441 
 442 
 443        When  dd reads from a pipe, using the  ibs=X and  obs=Y operands, the
 444        output will always be blocked in chunks of size Y. When bs=Z is used,
 445        the output blocks will be whatever was available to be read from the
 446        pipe at the time.
 447 
 448 
 449        When using dd to copy files to a tape device, the file size must be a
 450        multiple of the device sector size (for example, 512 Kbyte).  To  copy
 451        files of arbitrary size to a tape device, use  tar(1) or  cpio(1).
 452 
 453 
 454 
 455                                December 12, 2014                        DD(1M)