📄 dd.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>dd</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="dd"></a> <a name="tag_04_34"></a><!-- dd --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_34_01"></a>NAME</h4><blockquote>dd - convert and copy a file</blockquote><h4><a name="tag_04_34_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>dd</tt> <b>[</b><i>operand</i> <tt>...</tt><b>]</b></code></p></blockquote><h4><a name="tag_04_34_03"></a>DESCRIPTION</h4><blockquote><p>The <i>dd</i> utility shall copy the specified input file to the specified output file with possible conversions using specificinput and output block sizes. It shall read the input one block at a time, using the specified input block size; it shall thenprocess the block of data actually returned, which could be smaller than the requested block size. It shall apply any conversionsthat have been specified and write the resulting data to the output in blocks of the specified output block size. If the <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 requested, thedata returned from each input block shall be written as a separate output block; if the read returns less than a full block and the<b>sync</b> conversion is not specified, the resulting output block shall be the same size as the input block. 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 requested, theinput shall be processed and collected into full-sized output blocks until the end of the input is reached.</p><p>The processing order shall be as follows:</p><ol><li><p>An input block is read.</p></li><li><p>If the input block is shorter than the specified input block size and the <b>sync</b> conversion is specified, null bytes shallbe appended to the input data up to the specified size. (If either <b>block</b> or <b>unblock</b> is also specified, <space>sshall be appended instead of null bytes.) The remaining conversions and output shall include the pad characters as if they had beenread from the input.</p></li><li><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, theresulting data shall be written to the output as a single block, and the remaining steps are omitted.</p></li><li><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 bytesin the input block, the last byte in the input record shall not be swapped.</p></li><li><p>Any remaining conversions ( <b>block</b>, <b>unblock</b>, <b>lcase</b>, and <b>ucase</b>) shall be performed. These conversionsshall operate on the input data independently of the input blocking; an input or output fixed-length record may span blockboundaries.</p></li><li><p>The data resulting from input or conversion or both shall be aggregated into output blocks of the specified size. After the endof input is reached, any remaining output shall be written as a block without padding if <b>conv</b>= <b>sync</b> is not specified;thus, the final output block may be shorter than the output block size.</p></li></ol></blockquote><h4><a name="tag_04_34_04"></a>OPTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_34_05"></a>OPERANDS</h4><blockquote><p>All of the operands shall be processed before any input is read. The following operands shall be supported:</p><dl compact><dt><b>if</b>=<i>file</i></dt><dd>Specify the input pathname; the default is standard input.</dd><dt><b>of</b>=<i>file</i></dt><dd>Specify the output pathname; the default is standard output. If the <b>seek</b>= <i>expr</i> conversion is not also specified,the output file shall be truncated before the copy begins if an explicit <b>of</b>= <i>file</i> operand is specified, unless<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, theeffect of the copy shall be to preserve the blocks in the output file over which <i>dd</i> seeks, but no other portion of theoutput file shall be preserved. (If the size of the seek plus the size of the input file is less than the previous size of theoutput file, the output file shall be shortened by the copy.)</dd><dt><b>ibs</b>=<i>expr</i></dt><dd>Specify the input block size, in bytes, by <i>expr</i> (default is 512).</dd><dt><b>obs</b>=<i>expr</i></dt><dd>Specify the output block size, in bytes, by <i>expr</i> (default is 512).</dd><dt><b>bs</b>=<i>expr</i></dt><dd>Set both input and output block sizes to <i>expr</i> bytes, superseding <b>ibs</b>= and <b>obs</b>=. If no conversion otherthan <b>sync</b>, <b>noerror</b>, and <b>notrunc</b> is specified, each input block shall be copied to the output as a single blockwithout aggregating short blocks.</dd><dt><b>cbs</b>=<i>expr</i></dt><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>=is omitted or given a value of zero, using <b>block</b> or <b>unblock</b> produces unspecified results. <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The application shall ensure that this operand is also specified if the <b>conv</b>= operand is specified with a value of<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 asdescribed for the <b>unblock</b> value, except that characters are converted to ASCII before any trailing <space>s aredeleted. For <b>conv</b>= operands with <b>ebcdic</b> or <b>ibm</b> values, the input is handled as described for the <b>block</b>value except that the characters are converted to EBCDIC or IBM EBCDIC, respectively, after any trailing <space>s are added.<img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd><dt><b>skip</b>=<i>n</i></dt><dd>Skip <i>n</i> input blocks (using the specified input block size) before starting to copy. On seekable files, theimplementation shall read the blocks or seek past them; on non-seekable files, the blocks shall be read and the data shall bediscarded.</dd><dt><b>seek</b>=<i>n</i></dt><dd>Skip <i>n</i> blocks (using the specified output block size) from the beginning of the output file before copying. Onnon-seekable files, existing blocks shall be read and space from the current end-of-file to the specified offset, if any, filledwith null bytes; on seekable files, the implementation shall seek to the specified offset or read the blocks as described fornon-seekable files.</dd><dt><b>count</b>=<i>n</i></dt><dd>Copy only <i>n</i> input blocks.</dd><dt><b>conv</b>=<i>value</i><b>[</b>,<i>value</i> ...<b>]</b></dt><dd><br>Where <i>value</i>s are comma-separated symbols from the following list: <dl compact><dt><b>ascii</b></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Convert EBCDIC to ASCII; see <a href="#tagtcjh_12">ASCII to EBCDIC Conversion</a> . <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><b>ebcdic</b></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Convert ASCII to EBCDIC; see <a href="#tagtcjh_12">ASCII to EBCDIC Conversion</a> . <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><b>ibm</b></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Convert ASCII to a different EBCDIC set; see <a href="#tagtcjh_13">ASCII to IBM EBCDIC Conversion</a> .</dd></dl><p>The <b>ascii</b>, <b>ebcdic</b>, and <b>ibm</b> values are mutually-exclusive. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><dl compact><dt><b>block</b></dt><dd>Treat the input as a sequence of <newline>-terminated or end-of-file-terminated variable-length records independent ofthe input block boundaries. Each record shall be converted to a record with a fixed length specified by the conversion block size.Any <newline> shall be removed from the input line; <space>s shall be appended to lines that are shorter than theirconversion block size to fill the block. Lines that are longer than the conversion block size shall be truncated to the largestnumber of characters that fit into that size; the number of truncated lines shall be reported (see the STDERR section). <p>The <b>block</b> and <b>unblock</b> values are mutually-exclusive.</p></dd><dt><b>unblock</b></dt><dd>Convert fixed-length records to variable length. Read a number of bytes equal to the conversion block size (or the number ofbytes remaining in the input, if less than the conversion block size), delete all trailing <space>s, and append a<newline>.</dd><dt><b>lcase</b></dt><dd>Map uppercase characters specified by the <i>LC_CTYPE</i> keyword <b>tolower</b> to the corresponding lowercase character.Characters for which no mapping is specified shall not be modified by this conversion. <p>The <b>lcase</b> and <b>ucase</b> symbols are mutually-exclusive.</p></dd><dt><b>ucase</b></dt><dd>Map lowercase characters specified by the <i>LC_CTYPE</i> keyword <b>toupper</b> to the corresponding uppercase character.Characters for which no mapping is specified shall not be modified by this conversion.</dd><dt><b>swab</b></dt><dd>Swap every pair of input bytes.</dd><dt><b>noerror</b></dt><dd>Do not stop processing on an input error. When an input error occurs, a diagnostic message shall be written on standard error,followed by the current input and output block counts in the same format as used at completion (see the STDERR section). If the<b>sync</b> conversion is specified, the missing input shall be replaced with null bytes and processed normally; otherwise, theinput block shall be omitted from the output.</dd><dt><b>notrunc</b></dt><dd>Do not truncate the output file. Preserve blocks in the output file not explicitly written by this invocation of the <i>dd</i>utility. (See also the preceding <b>of</b>= <i>file</i> operand.)</dd><dt><b>sync</b></dt><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> isalso specified, append <space>s, rather than null bytes.)</dd></dl></dd></dl><p>The behavior is unspecified if operands other than <b>conv</b>= are specified more than once.</p><p>For the <b>bs</b>=, <b>cbs</b>=, <b>ibs</b>=, and <b>obs</b>= operands, the application shall supply an expression specifying asize in bytes. The expression, <i>expr</i>, can be:</p><ol><li><p>A positive decimal number</p></li><li><p>A positive decimal number followed by <i>k</i>, specifying multiplication by 1024</p></li><li><p>A positive decimal number followed by <i>b</i>, specifying multiplication by 512</p></li><li><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 theindicated values</p></li></ol><p>All of the operands are processed before any input is read.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The following two tables display the octal number character values used for the <b>ascii</b> and <b>ebcdic</b> conversions (firsttable) and for the <b>ibm</b> conversion (second table). In both tables, the ASCII values are the row and column headers and theEBCDIC values are found at their intersections. For example, ASCII 0012 (LF) is the second row, third column, yielding 0045 inEBCDIC. The inverted tables (for EBCDIC to ASCII conversion) are not shown, but are in one-to-one correspondence with these tables.The differences between the two tables are highlighted by small boxes drawn around five entries. <img src="../images/opt-end.gif"alt="[Option End]" border="0"><br></p><center><b><a name="tagtcjh_12"></a> Table: ASCII to EBCDIC Conversion</b></center><img src=".././Figures/ascebc.gif"><br><center><b><a name="tagtcjh_13"></a> Table: ASCII to IBM EBCDIC Conversion</b></center><img src=".././Figures/ascibm.gif"></blockquote><h4><a name="tag_04_34_06"></a>STDIN</h4><blockquote><p>If no <b>if</b>= operand is specified, the standard input shall be used. See the INPUT FILES section.</p></blockquote><h4><a name="tag_04_34_07"></a>INPUT FILES</h4><blockquote><p>The input file can be any file type.</p></blockquote><h4><a name="tag_04_34_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>dd</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -