isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

dd.html (31806B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>dd</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/date.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/delta.html" accesskey="N">Next
     19 &gt;&gt;&gt;</a></td>
     20 </tr>
     21 </table>
     22 <hr align="left" width="100%"></div>
     23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     24 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     25 IEEE Std 1003.1-2024<br>
     26 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     27 <hr size="2" noshade>
     28 <a name="top" id="top"></a> <a name="dd" id="dd"></a> <a name="tag_20_31" id="tag_20_31"></a><!-- dd -->
     29 <h4 class="mansect"><a name="tag_20_31_01" id="tag_20_31_01"></a>NAME</h4>
     30 <blockquote>dd — convert and copy a file</blockquote>
     31 <h4 class="mansect"><a name="tag_20_31_02" id="tag_20_31_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>dd</tt> <b>[</b><i>operand</i><tt>...</tt><b>]</b></code></p>
     34 </blockquote>
     35 <h4 class="mansect"><a name="tag_20_31_03" id="tag_20_31_03"></a>DESCRIPTION</h4>
     36 <blockquote>
     37 <p>The <i>dd</i> utility shall copy the specified input file to the specified output file with possible conversions using specific
     38 input and output block sizes. It shall read the input one block at a time, using the specified input block size; it shall then
     39 process the block of data actually returned, which could be smaller than the requested block size. It shall apply any conversions
     40 that have been specified and write the resulting data to the output in blocks of the specified output block size. If the
     41 <b>bs</b>=<i>expr</i> operand is specified and no conversions other than <b>sync</b>, <b>noerror</b>, or <b>notrunc</b> are
     42 requested, the data returned from each input block shall be written as a separate output block; if the read returns less than a
     43 full block and the <b>sync</b> conversion is not specified, the resulting output block shall be the same size as the input block.
     44 If the <b>bs</b>=<i>expr</i> operand is not specified, or a conversion other than <b>sync</b>, <b>noerror</b>, or <b>notrunc</b> is
     45 requested, the input shall be processed and collected into full-sized output blocks until the end of the input is reached.</p>
     46 <p>The processing order shall be as follows:</p>
     47 <ol>
     48 <li>
     49 <p>An input block is read. If the <b>iflags</b>=fullblock operand is specified, this might entail multiple reads; otherwise, the
     50 input block shall be used even if the read was shorter than the specified block size.</p>
     51 </li>
     52 <li>
     53 <p>If the input block is shorter than the specified input block size and the <b>sync</b> conversion is specified, null bytes shall
     54 be appended to the input data up to the specified size. (If either <b>block</b> or <b>unblock</b> is also specified, &lt;space&gt;
     55 characters shall be appended instead of null bytes.) The remaining conversions and output shall include the pad characters as if
     56 they had been read from the input.</p>
     57 </li>
     58 <li>
     59 <p>If the <b>bs</b>=<i>expr</i> operand is specified and no conversion other than <b>sync</b> or <b>noerror</b> is requested, the
     60 resulting data shall be written to the output as a single block, and the remaining steps are omitted.</p>
     61 </li>
     62 <li>
     63 <p>If the <b>swab</b> conversion is specified, each pair of input data bytes shall be swapped. If there is an odd number of bytes
     64 in the input block, the last byte in the input record shall not be swapped.</p>
     65 </li>
     66 <li>
     67 <p>Any remaining conversions (<b>block</b>, <b>unblock</b>, <b>lcase</b>, and <b>ucase</b>) shall be performed. These conversions
     68 shall operate on the input data independently of the input blocking; an input or output fixed-length record may span block
     69 boundaries.</p>
     70 </li>
     71 <li>
     72 <p>The data resulting from input or conversion or both shall be aggregated into output blocks of the specified size. After the end
     73 of input is reached, any remaining output shall be written as a block without padding if <b>conv</b>=<b>sync</b> is not specified;
     74 thus, the final output block may be shorter than the output block size.</p>
     75 </li>
     76 </ol>
     77 </blockquote>
     78 <h4 class="mansect"><a name="tag_20_31_04" id="tag_20_31_04"></a>OPTIONS</h4>
     79 <blockquote>
     80 <p>None.</p>
     81 </blockquote>
     82 <h4 class="mansect"><a name="tag_20_31_05" id="tag_20_31_05"></a>OPERANDS</h4>
     83 <blockquote>
     84 <p>All of the operands shall be processed before any input is read. The following operands shall be supported:</p>
     85 <dl compact>
     86 <dd></dd>
     87 <dt><b>if</b>=<i>file</i></dt>
     88 <dd>Specify the input pathname; the default is standard input.</dd>
     89 <dt><b>of</b>=<i>file</i></dt>
     90 <dd>Specify the output pathname; the default is standard output. If the <b>seek</b>=<i>expr</i> conversion is not also specified,
     91 the output file shall be truncated before the copy begins if an explicit <b>of</b>=<i>file</i> operand is specified, unless
     92 <b>conv</b>=<b>notrunc</b> is specified. If <b>seek</b>=<i>expr</i> is specified, but <b>conv</b>=<b>notrunc</b> is not, the effect
     93 of the copy shall be to preserve the blocks in the output file over which <i>dd</i> seeks, but no other portion of the output file
     94 shall be preserved. (If the size of the seek plus the size of the input file is less than the previous size of the output file, the
     95 output file shall be shortened by the copy. If the input file is empty and either the size of the seek is greater than the previous
     96 size of the output file or the output file did not previously exist, the size of the output file shall be set to the file offset
     97 after the seek.)</dd>
     98 <dt><b>ibs</b>=<i>expr</i></dt>
     99 <dd>Specify the input block size, in bytes, by <i>expr</i> (default is 512).</dd>
    100 <dt><b>obs</b>=<i>expr</i></dt>
    101 <dd>Specify the output block size, in bytes, by <i>expr</i> (default is 512).</dd>
    102 <dt><b>bs</b>=<i>expr</i></dt>
    103 <dd>Set both input and output block sizes to <i>expr</i> bytes, superseding <b>ibs</b>= and <b>obs</b>=. If no conversion other
    104 than <b>sync</b>, <b>noerror</b>, and <b>notrunc</b> is specified, each input block shall be copied to the output as a single block
    105 without aggregating short blocks.</dd>
    106 <dt><b>cbs</b>=<i>expr</i></dt>
    107 <dd>Specify the conversion block size for <b>block</b> and <b>unblock</b> in bytes by <i>expr</i> (default is zero). If <b>cbs</b>=
    108 is omitted or given a value of zero, using <b>block</b> or <b>unblock</b> produces unspecified results.
    109 <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    110 The application shall ensure that this operand is also specified if the <b>conv</b>= operand is specified with a value of
    111 <b>ascii</b>, <b>ebcdic</b>, or <b>ibm</b>. For a <b>conv</b>= operand with an <b>ascii</b> value, the input is handled as
    112 described for the <b>unblock</b> value, except that characters are converted to ASCII before any trailing &lt;space&gt; characters
    113 are deleted. For <b>conv</b>= operands with <b>ebcdic</b> or <b>ibm</b> values, the input is handled as described for the
    114 <b>block</b> value except that the characters are converted to EBCDIC or IBM EBCDIC, respectively, after any trailing &lt;space&gt;
    115 characters are added. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
    116 </dd>
    117 <dt><b>skip</b>=<i>n</i></dt>
    118 <dd>Skip <i>n</i> input blocks (using the specified input block size) before starting to copy. On seekable files, the
    119 implementation shall read the blocks or seek past them; on non-seekable files, the blocks shall be read and the data shall be
    120 discarded.</dd>
    121 <dt><b>seek</b>=<i>n</i></dt>
    122 <dd>Skip <i>n</i> blocks (using the specified output block size) from the beginning of the output file before copying. On
    123 non-seekable files, existing blocks shall be read and space from the current end-of-file to the specified offset, if any, filled
    124 with null bytes; on seekable files, the implementation shall seek to the specified offset or read the blocks as described for
    125 non-seekable files.</dd>
    126 <dt><b>count</b>=<i>n</i></dt>
    127 <dd>Copy only <i>n</i> input blocks. If <i>n</i> is zero, it is unspecified whether no blocks or all blocks are copied.</dd>
    128 <dt><b>conv</b>=<i>value</i><b>[</b>,<i>value</i>&nbsp;...<b>]</b></dt>
    129 <dd><br>
    130 Where <i>value</i>s are &lt;comma&gt;-separated symbols from the following list:
    131 <dl compact>
    132 <dd></dd>
    133 <dt><b>ascii</b></dt>
    134 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    135 Convert EBCDIC to ASCII; see <a href="#tagtcjh_18">ASCII to EBCDIC Conversion</a> . <img src="../images/opt-end.gif" alt=
    136 "[Option End]" border="0"></dd>
    137 <dt><b>ebcdic</b></dt>
    138 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    139 Convert ASCII to EBCDIC; see <a href="#tagtcjh_18">ASCII to EBCDIC Conversion</a> . <img src="../images/opt-end.gif" alt=
    140 "[Option End]" border="0"></dd>
    141 <dt><b>ibm</b></dt>
    142 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    143 Convert ASCII to a different EBCDIC set; see <a href="#tagtcjh_19">ASCII to IBM EBCDIC Conversion</a> . <img src=
    144 "../images/opt-end.gif" alt="[Option End]" border="0"></dd>
    145 </dl>
    146 <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    147 The <b>ascii</b>, <b>ebcdic</b>, and <b>ibm</b> values are mutually-exclusive. <img src="../images/opt-end.gif" alt="[Option End]"
    148 border="0"></p>
    149 <dl compact>
    150 <dd></dd>
    151 <dt><b>block</b></dt>
    152 <dd>Treat the input as a sequence of &lt;newline&gt;-terminated or end-of-file-terminated variable-length records independent of
    153 the input block boundaries. Each record shall be converted to a record with a fixed length specified by the conversion block size.
    154 Any &lt;newline&gt; shall be removed from the input line; &lt;space&gt; characters shall be appended to lines that are shorter than
    155 their conversion block size to fill the block. Lines that are longer than the conversion block size shall be truncated to the
    156 largest number of characters that fit into that size; the number of truncated lines shall be reported (see the STDERR section).
    157 <p>The <b>block</b> and <b>unblock</b> values are mutually-exclusive.</p>
    158 </dd>
    159 <dt><b>unblock</b></dt>
    160 <dd>Convert fixed-length records to variable length. Read a number of bytes equal to the conversion block size (or the number of
    161 bytes remaining in the input, if less than the conversion block size), delete all trailing &lt;space&gt; characters, and append a
    162 &lt;newline&gt;.</dd>
    163 <dt><b>lcase</b></dt>
    164 <dd>Map uppercase characters specified by the <i>LC_CTYPE</i> keyword <b>tolower</b> to the corresponding lowercase character.
    165 Characters for which no mapping is specified shall not be modified by this conversion.
    166 <p>The <b>lcase</b> and <b>ucase</b> symbols are mutually-exclusive.</p>
    167 </dd>
    168 <dt><b>ucase</b></dt>
    169 <dd>Map lowercase characters specified by the <i>LC_CTYPE</i> keyword <b>toupper</b> to the corresponding uppercase character.
    170 Characters for which no mapping is specified shall not be modified by this conversion.</dd>
    171 <dt><b>swab</b></dt>
    172 <dd>Swap every pair of input bytes.</dd>
    173 <dt><b>noerror</b></dt>
    174 <dd>Do not stop processing on an input error. When an input error occurs, a diagnostic message shall be written on standard error,
    175 followed by the current input and output block counts in the same format as used at completion (see the STDERR section). If the
    176 <b>sync</b> conversion is specified, the missing input shall be replaced with null bytes and processed normally; otherwise, the
    177 input block shall be omitted from the output.</dd>
    178 <dt><b>notrunc</b></dt>
    179 <dd>Do not truncate the output file. Preserve blocks in the output file not explicitly written by this invocation of the <i>dd</i>
    180 utility. (See also the preceding <b>of</b>=<i>file</i> operand.)</dd>
    181 <dt><b>sync</b></dt>
    182 <dd>Pad every input block to the size of the <b>ibs</b>= buffer, appending null bytes. (If either <b>block</b> or <b>unblock</b> is
    183 also specified, append &lt;space&gt; characters, rather than null bytes.)</dd>
    184 </dl>
    185 </dd>
    186 <dt><b>iflags</b>=fullblock</dt>
    187 <dd><br>
    188 Perform as many reads as required to reach the full input block size or end of file, rather than acting on partial reads. If this
    189 operand is in effect, then the <b>count</b>= operand refers to the number of full input blocks rather than reads. The behavior is
    190 unspecified if <b>iflags</b>=fullblock is requested alongside the <b>sync</b>, <b>block</b>, or <b>unblock</b> conversions.</dd>
    191 </dl>
    192 <p>The behavior is unspecified if operands other than <b>conv</b>= are specified more than once.</p>
    193 <p>For the <b>bs</b>=, <b>cbs</b>=, <b>ibs</b>=, and <b>obs</b>= operands, the application shall supply an expression specifying a
    194 size in bytes. The expression, <i>expr</i>, can be:</p>
    195 <ol>
    196 <li>
    197 <p>A positive decimal number</p>
    198 </li>
    199 <li>
    200 <p>A positive decimal number followed by <i>k</i>, specifying multiplication by 1024</p>
    201 </li>
    202 <li>
    203 <p>A positive decimal number followed by <i>b</i>, specifying multiplication by 512</p>
    204 </li>
    205 <li>
    206 <p>Two or more positive decimal numbers (with or without <i>k</i> or <i>b</i>) separated by <i>x</i>, specifying the product of the
    207 indicated values</p>
    208 </li>
    209 </ol>
    210 <p>All of the operands are processed before any input is read.</p>
    211 <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    212 The following two tables display the octal number character values used for the <b>ascii</b> and <b>ebcdic</b> conversions (first
    213 table) and for the <b>ibm</b> conversion (second table). In both tables, the ASCII values are the row and column headers and the
    214 EBCDIC values are found at their intersections. For example, ASCII 0012 (LF) is the second row, third column, yielding 0045 in
    215 EBCDIC. The inverted tables (for EBCDIC to ASCII conversion) are not shown, but are in one-to-one correspondence with these tables.
    216 The differences between the two tables are highlighted by small boxes drawn around five entries. <img src="../images/opt-end.gif"
    217 alt="[Option End]" border="0"><br></p>
    218 <p class="caption"><a name="tagtcjh_18" id="tagtcjh_18"></a> Table: ASCII to EBCDIC Conversion</p>
    219 <img src=".././Figures/ascebc.gif">
    220 <p class="caption"><a name="tagtcjh_19" id="tagtcjh_19"></a> Table: ASCII to IBM EBCDIC Conversion</p>
    221 <img src=".././Figures/ascibm.gif"></blockquote>
    222 <h4 class="mansect"><a name="tag_20_31_06" id="tag_20_31_06"></a>STDIN</h4>
    223 <blockquote>
    224 <p>If no <b>if</b>= operand is specified, the standard input shall be used. See the INPUT FILES section.</p>
    225 </blockquote>
    226 <h4 class="mansect"><a name="tag_20_31_07" id="tag_20_31_07"></a>INPUT FILES</h4>
    227 <blockquote>
    228 <p>The input file can be any file type.</p>
    229 </blockquote>
    230 <h4 class="mansect"><a name="tag_20_31_08" id="tag_20_31_08"></a>ENVIRONMENT VARIABLES</h4>
    231 <blockquote>
    232 <p>The following environment variables shall affect the execution of <i>dd</i>:</p>
    233 <dl compact>
    234 <dd></dd>
    235 <dt><i>LANG</i></dt>
    236 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    237 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    238 variables used to determine the values of locale categories.)</dd>
    239 <dt><i>LC_ALL</i></dt>
    240 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    241 <dt><i>LC_CTYPE</i></dt>
    242 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    243 opposed to multi-byte characters in arguments and input files), the classification of characters as uppercase or lowercase, and the
    244 mapping of characters from one case to the other.</dd>
    245 <dt><i>LC_MESSAGES</i></dt>
    246 <dd><br>
    247 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and
    248 informative messages written to standard output.</dd>
    249 <dt><i>NLSPATH</i></dt>
    250 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    251 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    252 "0"></dd>
    253 </dl>
    254 </blockquote>
    255 <h4 class="mansect"><a name="tag_20_31_09" id="tag_20_31_09"></a>ASYNCHRONOUS EVENTS</h4>
    256 <blockquote>
    257 <p>For SIGINT, the <i>dd</i> utility shall interrupt its current processing, write status information to standard error, and
    258 terminate abnormally as if by the default action for SIGINT. One or more implementation defined non-job-control signals other than
    259 SIGABRT, SIGHUP, and SIGTERM may write status information to standard error and continue processing. All other signals (including
    260 job control signals, SIGABRT, SIGHUP, and SIGTERM) shall take their default action; see the ASYNCHRONOUS EVENTS section in <a href=
    261 "../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> .</p>
    262 </blockquote>
    263 <h4 class="mansect"><a name="tag_20_31_10" id="tag_20_31_10"></a>STDOUT</h4>
    264 <blockquote>
    265 <p>If no <b>of</b>= operand is specified, the standard output shall be used. The nature of the output depends on the operands
    266 selected.</p>
    267 </blockquote>
    268 <h4 class="mansect"><a name="tag_20_31_11" id="tag_20_31_11"></a>STDERR</h4>
    269 <blockquote>
    270 <p>On completion, <i>dd</i> shall write the number of input and output blocks to standard error. In the POSIX locale the following
    271 formats shall be used:</p>
    272 <pre>
    273 <tt>"%u+%u records in\n", &lt;</tt><i>number of whole input blocks</i><tt>&gt;,
    274     &lt;</tt><i>number of partial input blocks</i><tt>&gt;
    275 <br>
    276 "%u+%u records out\n", &lt;</tt><i>number of whole output blocks</i><tt>&gt;,
    277     &lt;</tt><i>number of partial output blocks</i><tt>&gt;
    278 </tt></pre>
    279 <p>A partial input block is one for which <a href="../functions/read.html"><i>read</i>()</a> returned less than the input block
    280 size. A partial output block is one that was written with fewer bytes than specified by the output block size.</p>
    281 <p>In addition, when there is at least one truncated block, the number of truncated blocks shall be written to standard error. In
    282 the POSIX locale, the format shall be:</p>
    283 <pre>
    284 <tt>"%u truncated %s\n", &lt;</tt><i>number of truncated blocks</i><tt>&gt;, "record" (if
    285     &lt;</tt><i>number of truncated blocks</i><tt>&gt; is one) "records" (otherwise)
    286 </tt></pre>
    287 <p>Diagnostic messages may also be written to standard error.</p>
    288 </blockquote>
    289 <h4 class="mansect"><a name="tag_20_31_12" id="tag_20_31_12"></a>OUTPUT FILES</h4>
    290 <blockquote>
    291 <p>If the <b>of</b>= operand is used, the output shall be the same as described in the STDOUT section.</p>
    292 </blockquote>
    293 <h4 class="mansect"><a name="tag_20_31_13" id="tag_20_31_13"></a>EXTENDED DESCRIPTION</h4>
    294 <blockquote>
    295 <p>None.</p>
    296 </blockquote>
    297 <h4 class="mansect"><a name="tag_20_31_14" id="tag_20_31_14"></a>EXIT STATUS</h4>
    298 <blockquote>
    299 <p>The following exit values shall be returned:</p>
    300 <dl compact>
    301 <dd></dd>
    302 <dt>&nbsp;0</dt>
    303 <dd>Successful completion.</dd>
    304 <dt>&gt;0</dt>
    305 <dd>An error occurred.</dd>
    306 </dl>
    307 </blockquote>
    308 <h4 class="mansect"><a name="tag_20_31_15" id="tag_20_31_15"></a>CONSEQUENCES OF ERRORS</h4>
    309 <blockquote>
    310 <p>If an input error is detected and the <b>noerror</b> conversion has not been specified, any partial output block shall be
    311 written to the output file, a diagnostic message shall be written, and the copy operation shall be discontinued. If some other
    312 error is detected, a diagnostic message shall be written and the copy operation shall be discontinued.</p>
    313 </blockquote>
    314 <hr>
    315 <div class="box"><em>The following sections are informative.</em></div>
    316 <h4 class="mansect"><a name="tag_20_31_16" id="tag_20_31_16"></a>APPLICATION USAGE</h4>
    317 <blockquote>
    318 <p>The input and output block size can be specified to take advantage of raw physical I/O.</p>
    319 <p>There are many different versions of the EBCDIC codesets. The ASCII and EBCDIC conversions specified for the <i>dd</i> utility
    320 perform conversions for the version specified by the tables.</p>
    321 <p>Using the <b>count</b>= operand of <i>dd</i> with a pipe or FIFO as the input can lead to surprising results, since these file
    322 types are prone to encountering short reads for any input block size other than 1. Unless the <b>iflags</b>=fullblock operand is in
    323 effect, <i>dd</i> will stop after the specified number of reads, rather than full input blocks, and therefore can often result in
    324 fewer bytes being output than the product of the count and input block size.</p>
    325 </blockquote>
    326 <h4 class="mansect"><a name="tag_20_31_17" id="tag_20_31_17"></a>EXAMPLES</h4>
    327 <blockquote>
    328 <p>The following command:</p>
    329 <pre>
    330 <tt>dd if=/dev/rmt0h  of=/dev/rmt1h
    331 </tt></pre>
    332 <p>copies from tape drive 0 to tape drive 1, using a common historical device naming convention.</p>
    333 <p>The following command:</p>
    334 <pre>
    335 <tt>dd ibs=10  skip=1
    336 </tt></pre>
    337 <p>strips the first 10 bytes from standard input.</p>
    338 <p>This example reads an EBCDIC tape blocked ten 80-byte EBCDIC card images per block into the ASCII file <b>x</b>:</p>
    339 <pre>
    340 <tt>dd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase
    341 </tt></pre></blockquote>
    342 <h4 class="mansect"><a name="tag_20_31_18" id="tag_20_31_18"></a>RATIONALE</h4>
    343 <blockquote>
    344 <p>The OPTIONS section is listed as &quot;None&quot; because there are no options recognized by historical <i>dd</i> utilities. Certainly,
    345 many of the operands could have been designed to use the Utility Syntax Guidelines, which would have resulted in the classic
    346 hyphenated option letters. In this version of this volume of POSIX.1-2024, <i>dd</i> retains its curious JCL-like syntax due to the
    347 large number of applications that depend on the historical implementation.</p>
    348 <p>A suggested implementation technique for <b>conv</b>=<b>noerror</b>,<b>sync</b> is to zero (or &lt;space&gt;-fill, if
    349 <b>block</b>ing or <b>unblock</b>ing) the input buffer before each read and to write the contents of the input buffer to the output
    350 even after an error. In this manner, any data transferred to the input buffer before the error was detected is preserved. Another
    351 point is that a failed read on a regular file or a disk generally does not increment the file offset, and <i>dd</i> must then seek
    352 past the block on which the error occurred; otherwise, the input error occurs repetitively. When the input is a magnetic tape,
    353 however, the tape normally has passed the block containing the error when the error is reported, and thus no seek is necessary.</p>
    354 <p>The default <b>ibs</b>= and <b>obs</b>= sizes are specified as 512 bytes because there are historical (largely portable) scripts
    355 that assume these values. If they were left unspecified, unusual results could occur if an implementation chose an odd block
    356 size.</p>
    357 <p>Historical implementations of <i>dd</i> used <a href="../functions/creat.html"><i>creat</i>()</a> when processing
    358 <b>of</b>=<i>file</i>. This makes the <b>seek</b>= operand unusable except on special files. The <b>conv</b>=<b>notrunc</b> feature
    359 was added because more recent BSD-based implementations use <a href="../functions/open.html"><i>open</i>()</a> (without O_TRUNC)
    360 instead of <a href="../functions/creat.html"><i>creat</i>()</a>, but they fail to delete output file contents after the data
    361 copied.</p>
    362 <p>The <i>w</i> multiplier (historically meaning <i>word</i>), is used in System V to mean 2 and in 4.2 BSD to mean 4. Since
    363 <i>word</i> is inherently non-portable, its use is not supported by this volume of POSIX.1-2024.</p>
    364 <p>Standard EBCDIC does not have the characters <tt>'['</tt> and <tt>']'</tt>. The values used in the table are taken from a common
    365 print train that does contain them. Other than those characters, the print train values are not filled in, but appear to provide
    366 some of the motivation for the historical choice of translations reflected here.</p>
    367 <p>The Standard EBCDIC table provides a 1:1 translation for all 256 bytes.</p>
    368 <p>The IBM EBCDIC table does not provide such a translation. The marked cells in the tables differ in such a way that:</p>
    369 <ol>
    370 <li>
    371 <p>EBCDIC 0112 (<tt>'¢'</tt>) and 0152 (broken pipe) do not appear in the table.</p>
    372 </li>
    373 <li>
    374 <p>EBCDIC 0137 (<tt>'¬'</tt>) translates to/from ASCII 0236 (<tt>'^'</tt>). In the standard table, EBCDIC 0232 (no graphic) is
    375 used.</p>
    376 </li>
    377 <li>
    378 <p>EBCDIC 0241 (<tt>'~'</tt>) translates to/from ASCII 0176 (<tt>'~'</tt>). In the standard table, EBCDIC 0137 (<tt>'¬'</tt>) is
    379 used.</p>
    380 </li>
    381 <li>
    382 <p>0255 (<tt>'['</tt>) and 0275 (<tt>']'</tt>) appear twice, once in the same place as for the standard table and once in place of
    383 0112 (<tt>'¢'</tt>) and 0241 (<tt>'~'</tt>).</p>
    384 </li>
    385 </ol>
    386 <p>In net result:</p>
    387 <blockquote>EBCDIC 0275 (<tt>']'</tt>) displaced EBCDIC 0241 (<tt>'~'</tt>) in cell 0345.
    388 <p>&nbsp;&nbsp;&nbsp;&nbsp;That displaced EBCDIC 0137 (<tt>'¬'</tt>) in cell 0176.</p>
    389 <p>&nbsp;&nbsp;&nbsp;&nbsp;That displaced EBCDIC 0232 (no graphic) in cell 0136.</p>
    390 <p>&nbsp;&nbsp;&nbsp;&nbsp;That replaced EBCDIC 0152 (broken pipe) in cell 0313.</p>
    391 <p>EBCDIC 0255 (<tt>'['</tt>) replaced EBCDIC 0112 (<tt>'¢'</tt>).</p>
    392 </blockquote>
    393 <p>This translation, however, reflects historical practice that (ASCII) <tt>'~'</tt> and <tt>'¬'</tt> were often mapped to each
    394 other, as were <tt>'['</tt> and <tt>'¢'</tt>; and <tt>']'</tt> and (EBCDIC) <tt>'~'</tt>.</p>
    395 <p>The <b>cbs</b> operand is required if any of the <b>ascii</b>, <b>ebcdic</b>, or <b>ibm</b> operands are specified. For the
    396 <b>ascii</b> operand, the input is handled as described for the <b>unblock</b> operand except that characters are converted to
    397 ASCII before the trailing &lt;space&gt; characters are deleted. For the <b>ebcdic</b> and <b>ibm</b> operands, the input is handled
    398 as described for the <b>block</b> operand except that the characters are converted to EBCDIC or IBM EBCDIC after the trailing
    399 &lt;space&gt; characters are added.</p>
    400 <p>The <b>block</b> and <b>unblock</b> keywords are from historical BSD practice.</p>
    401 <p>The consistent use of the word <b>record</b> in standard error messages matches most historical practice. An earlier version of
    402 System V used <b>block</b>, but this has been updated in more recent releases.</p>
    403 <p>Early proposals only allowed two numbers separated by <b>x</b> to be used in a product when specifying <b>bs</b>=, <b>cbs</b>=,
    404 <b>ibs</b>=, and <b>obs</b>= sizes. This was changed to reflect the historical practice of allowing multiple numbers in the product
    405 as provided by Version 7 and all releases of System V and BSD.</p>
    406 <p>A change to the <b>swab</b> conversion is required to match historical practice and is the result of IEEE PASC Interpretations
    407 1003.2 #03 and #04, submitted for the ISO&nbsp;POSIX-2:1993 standard.</p>
    408 <p>A change to the handling of SIGINT is required to match historical practice and is the result of IEEE PASC Interpretation 1003.2
    409 #06 submitted for the ISO&nbsp;POSIX-2:1993 standard.</p>
    410 </blockquote>
    411 <h4 class="mansect"><a name="tag_20_31_19" id="tag_20_31_19"></a>FUTURE DIRECTIONS</h4>
    412 <blockquote>
    413 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a
    414 &lt;newline&gt; character, implementations are encouraged to treat this as an error. A future version of this standard may require
    415 implementations to treat this as an error.</p>
    416 <p>A future version of this standard may introduce the SIGINFO signal; on platforms where such a signal is available, it is
    417 recommended that this signal be used for reporting status without terminating the process.</p>
    418 </blockquote>
    419 <h4 class="mansect"><a name="tag_20_31_20" id="tag_20_31_20"></a>SEE ALSO</h4>
    420 <blockquote>
    421 <p><a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> , <a href=
    422 "../utilities/sed.html#"><i>sed</i></a> , <a href="../utilities/tr.html#"><i>tr</i></a></p>
    423 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a></p>
    424 </blockquote>
    425 <h4 class="mansect"><a name="tag_20_31_21" id="tag_20_31_21"></a>CHANGE HISTORY</h4>
    426 <blockquote>
    427 <p>First released in Issue 2.</p>
    428 </blockquote>
    429 <h4 class="mansect"><a name="tag_20_31_22" id="tag_20_31_22"></a>Issue 5</h4>
    430 <blockquote>
    431 <p>The second paragraph of the <b>cbs</b>= description is reworded and marked EX.</p>
    432 <p>The FUTURE DIRECTIONS section is added.</p>
    433 </blockquote>
    434 <h4 class="mansect"><a name="tag_20_31_23" id="tag_20_31_23"></a>Issue 6</h4>
    435 <blockquote>
    436 <p>Changes are made to <b>swab</b> conversion and SIGINT handling to align with the IEEE&nbsp;P1003.2b draft standard.</p>
    437 <p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p>
    438 <p>IEEE PASC Interpretation 1003.2 #209 is applied, clarifying the interaction between <i>dd</i> <b>of</b>=<i>file</i> and
    439 <b>conv</b>=<b>notrunc</b>.</p>
    440 </blockquote>
    441 <h4 class="mansect"><a name="tag_20_31_24" id="tag_20_31_24"></a>Issue 7</h4>
    442 <blockquote>
    443 <p>Austin Group Interpretation 1003.1-2001 #102 is applied.</p>
    444 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    445 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0081 [907] is applied.</p>
    446 </blockquote>
    447 <h4 class="mansect"><a name="tag_20_31_25" id="tag_20_31_25"></a>Issue 8</h4>
    448 <blockquote>
    449 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that
    450 have the encoded value of a &lt;newline&gt; character.</p>
    451 <p>Austin Group Defect 406 is applied, adding the <b>iflags</b>=fullblock operand.</p>
    452 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    453 <p>Austin Group Defect 1159 is applied, changing the ASYNCHRONOUS EVENTS and FUTURE DIRECTIONS sections.</p>
    454 <p>Austin Group Defect 1497 is applied, changing the EXIT STATUS section.</p>
    455 </blockquote>
    456 <div class="box"><em>End of informative text.</em></div>
    457 <hr>
    458 <p>&nbsp;</p>
    459 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    460 <hr size="2" noshade>
    461 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    462 POSIX™ is a Trademark of The IEEE.<br>
    463 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    464 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    465 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    466 ]</font></center>
    467 <hr size="2" noshade>
    468 <div class="NAVHEADER">
    469 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    470 <tr class="nav">
    471 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/date.html" accesskey="P">&lt;&lt;&lt;
    472 Previous</a></td>
    473 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    474 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/delta.html" accesskey="N">Next
    475 &gt;&gt;&gt;</a></td>
    476 </tr>
    477 </table>
    478 <hr align="left" width="100%"></div>
    479 </body>
    480 </html>