isposix

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

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

fold.html (14286B)


      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>fold</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/find.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/fuser.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="fold" id="fold"></a> <a name="tag_20_48" id="tag_20_48"></a><!-- fold -->
     29 <h4 class="mansect"><a name="tag_20_48_01" id="tag_20_48_01"></a>NAME</h4>
     30 <blockquote>fold — filter for folding lines</blockquote>
     31 <h4 class="mansect"><a name="tag_20_48_02" id="tag_20_48_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>fold</tt> <b>[</b><tt>-bs</tt><b>] [</b><tt>-w</tt> <i>width</i><b>] [</b><i>file</i><tt>...</tt><b>]</b></code></p>
     34 </blockquote>
     35 <h4 class="mansect"><a name="tag_20_48_03" id="tag_20_48_03"></a>DESCRIPTION</h4>
     36 <blockquote>
     37 <p>The <i>fold</i> utility is a filter that shall fold lines from its input files, breaking the lines to have a maximum of
     38 <i>width</i> column positions (or bytes, if the <b>-b</b> option is specified). Lines shall be broken by the insertion of a
     39 &lt;newline&gt; such that each output line (referred to later in this section as a <i>segment</i>) is the maximum width possible
     40 that does not exceed the specified number of column positions (or bytes). A line shall not be broken in the middle of a character.
     41 The behavior is undefined if <i>width</i> is less than the number of columns any single character in the input would occupy.</p>
     42 <p>If the &lt;carriage-return&gt;, &lt;backspace&gt;, or &lt;tab&gt; characters are encountered in the input, and the <b>-b</b>
     43 option is not specified, they shall be treated specially:</p>
     44 <dl compact>
     45 <dd></dd>
     46 <dt>&lt;backspace&gt;</dt>
     47 <dd>The current count of line width shall be decremented by one, although the count never shall become negative. The <i>fold</i>
     48 utility shall not insert a &lt;newline&gt; immediately before or after any &lt;backspace&gt;, unless the following character has a
     49 width greater than 1 and would cause the line width to exceed <i>width</i>.</dd>
     50 <dt>&lt;carriage-return&gt;</dt>
     51 <dd><br>
     52 The current count of line width shall be set to zero. The <i>fold</i> utility shall not insert a &lt;newline&gt; immediately before
     53 or after any &lt;carriage-return&gt;.</dd>
     54 <dt>&lt;tab&gt;</dt>
     55 <dd>Each &lt;tab&gt; encountered shall advance the column position pointer to the next tab stop. Tab stops shall be at each column
     56 position <i>n</i> such that <i>n</i> modulo 8 equals 1.</dd>
     57 </dl>
     58 </blockquote>
     59 <h4 class="mansect"><a name="tag_20_48_04" id="tag_20_48_04"></a>OPTIONS</h4>
     60 <blockquote>
     61 <p>The <i>fold</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     62 Guidelines</i></a> .</p>
     63 <p>The following options shall be supported:</p>
     64 <dl compact>
     65 <dd></dd>
     66 <dt><b>-b</b></dt>
     67 <dd>Count <i>width</i> in bytes rather than column positions.</dd>
     68 <dt><b>-s</b></dt>
     69 <dd>If a segment of a line contains a &lt;blank&gt; within the first <i>width</i> column positions (or bytes), break the line after
     70 the last such &lt;blank&gt; meeting the width constraints. If there is no &lt;blank&gt; meeting the requirements, the <b>-s</b>
     71 option shall have no effect for that output segment of the input line.</dd>
     72 <dt><b>-w&nbsp;</b><i>width</i></dt>
     73 <dd>Specify the maximum line length, in column positions (or bytes if <b>-b</b> is specified). The results are unspecified if
     74 <i>width</i> is not a positive decimal number. The default value shall be 80.</dd>
     75 </dl>
     76 </blockquote>
     77 <h4 class="mansect"><a name="tag_20_48_05" id="tag_20_48_05"></a>OPERANDS</h4>
     78 <blockquote>
     79 <p>The following operand shall be supported:</p>
     80 <dl compact>
     81 <dd></dd>
     82 <dt><i>file</i></dt>
     83 <dd>A pathname of a text file to be folded. If no <i>file</i> operands are specified, the standard input shall be used.</dd>
     84 </dl>
     85 </blockquote>
     86 <h4 class="mansect"><a name="tag_20_48_06" id="tag_20_48_06"></a>STDIN</h4>
     87 <blockquote>
     88 <p>The standard input shall be used if no <i>file</i> operands are specified, and shall be used if a <i>file</i> operand is
     89 <tt>'-'</tt> and the implementation treats the <tt>'-'</tt> as meaning standard input. Otherwise, the standard input shall not be
     90 used. See the INPUT FILES section.</p>
     91 </blockquote>
     92 <h4 class="mansect"><a name="tag_20_48_07" id="tag_20_48_07"></a>INPUT FILES</h4>
     93 <blockquote>
     94 <p>If the <b>-b</b> option is specified, the input files shall be text files except that the lines are not limited to {LINE_MAX}
     95 bytes in length. If the <b>-b</b> option is not specified, the input files shall be text files.</p>
     96 </blockquote>
     97 <h4 class="mansect"><a name="tag_20_48_08" id="tag_20_48_08"></a>ENVIRONMENT VARIABLES</h4>
     98 <blockquote>
     99 <p>The following environment variables shall affect the execution of <i>fold</i>:</p>
    100 <dl compact>
    101 <dd></dd>
    102 <dt><i>LANG</i></dt>
    103 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    104 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    105 variables used to determine the values of locale categories.)</dd>
    106 <dt><i>LC_ALL</i></dt>
    107 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    108 <dt><i>LC_CTYPE</i></dt>
    109 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    110 opposed to multi-byte characters in arguments and input files), and for the determination of the width in column positions each
    111 character would occupy on a constant-width font output device.</dd>
    112 <dt><i>LC_MESSAGES</i></dt>
    113 <dd><br>
    114 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    115 <dt><i>NLSPATH</i></dt>
    116 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    117 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    118 "0"></dd>
    119 </dl>
    120 </blockquote>
    121 <h4 class="mansect"><a name="tag_20_48_09" id="tag_20_48_09"></a>ASYNCHRONOUS EVENTS</h4>
    122 <blockquote>
    123 <p>Default.</p>
    124 </blockquote>
    125 <h4 class="mansect"><a name="tag_20_48_10" id="tag_20_48_10"></a>STDOUT</h4>
    126 <blockquote>
    127 <p>The standard output shall be a file containing a sequence of characters whose order shall be preserved from the input files,
    128 possibly with inserted &lt;newline&gt; characters.</p>
    129 </blockquote>
    130 <h4 class="mansect"><a name="tag_20_48_11" id="tag_20_48_11"></a>STDERR</h4>
    131 <blockquote>
    132 <p>The standard error shall be used only for diagnostic messages.</p>
    133 </blockquote>
    134 <h4 class="mansect"><a name="tag_20_48_12" id="tag_20_48_12"></a>OUTPUT FILES</h4>
    135 <blockquote>
    136 <p>None.</p>
    137 </blockquote>
    138 <h4 class="mansect"><a name="tag_20_48_13" id="tag_20_48_13"></a>EXTENDED DESCRIPTION</h4>
    139 <blockquote>
    140 <p>None.</p>
    141 </blockquote>
    142 <h4 class="mansect"><a name="tag_20_48_14" id="tag_20_48_14"></a>EXIT STATUS</h4>
    143 <blockquote>
    144 <p>The following exit values shall be returned:</p>
    145 <dl compact>
    146 <dd></dd>
    147 <dt>&nbsp;0</dt>
    148 <dd>All input files were processed successfully.</dd>
    149 <dt>&gt;0</dt>
    150 <dd>An error occurred.</dd>
    151 </dl>
    152 </blockquote>
    153 <h4 class="mansect"><a name="tag_20_48_15" id="tag_20_48_15"></a>CONSEQUENCES OF ERRORS</h4>
    154 <blockquote>
    155 <p>Default.</p>
    156 </blockquote>
    157 <hr>
    158 <div class="box"><em>The following sections are informative.</em></div>
    159 <h4 class="mansect"><a name="tag_20_48_16" id="tag_20_48_16"></a>APPLICATION USAGE</h4>
    160 <blockquote>
    161 <p>The <a href="../utilities/cut.html"><i>cut</i></a> and <i>fold</i> utilities can be used to create text files out of files with
    162 arbitrary line lengths. The <a href="../utilities/cut.html"><i>cut</i></a> utility should be used when the number of lines (or
    163 records) needs to remain constant. The <i>fold</i> utility should be used when the contents of long lines need to be kept
    164 contiguous.</p>
    165 <p>The <i>fold</i> utility is frequently used to send text files to printers that truncate, rather than fold, lines wider than the
    166 printer is able to print (usually 80 or 132 column positions).</p>
    167 </blockquote>
    168 <h4 class="mansect"><a name="tag_20_48_17" id="tag_20_48_17"></a>EXAMPLES</h4>
    169 <blockquote>
    170 <p>An example invocation that submits a file of possibly long lines to the printer (under the assumption that the user knows the
    171 line width of the printer to be assigned by <a href="../utilities/lp.html"><i>lp</i></a>):</p>
    172 <pre>
    173 <tt>fold -w 132 bigfile | lp
    174 </tt></pre></blockquote>
    175 <h4 class="mansect"><a name="tag_20_48_18" id="tag_20_48_18"></a>RATIONALE</h4>
    176 <blockquote>
    177 <p>Although terminal input in canonical processing mode requires the erase character (frequently set to &lt;backspace&gt;) to erase
    178 the previous character (not byte or column position), terminal output is not buffered and is extremely difficult, if not
    179 impossible, to parse correctly; the interpretation depends entirely on the physical device that actually displays/prints/stores the
    180 output. In all known internationalized implementations, the utilities producing output for mixed column-width output assume that a
    181 &lt;backspace&gt; character backs up one column position and outputs enough &lt;backspace&gt; characters to return to the start of
    182 the character when &lt;backspace&gt; is used to provide local line motions to support underlining and emboldening operations. Since
    183 <i>fold</i> without the <b>-b</b> option is dealing with these same constraints, &lt;backspace&gt; is always treated as backing up
    184 one column position rather than backing up one character.</p>
    185 <p>Historical versions of the <i>fold</i> utility assumed 1 byte was one character and occupied one column position when written
    186 out. This is no longer always true. Since the most common usage of <i>fold</i> is believed to be folding long lines for output to
    187 limited-length output devices, this capability was preserved as the default case. The <b>-b</b> option was added so that
    188 applications could <i>fold</i> files with arbitrary length lines into text files that could then be processed by the standard
    189 utilities. Note that although the width for the <b>-b</b> option is in bytes, a line is never split in the middle of a character.
    190 (It is unspecified what happens if a width is specified that is too small to hold a single character found in the input followed by
    191 a &lt;newline&gt;.)</p>
    192 <p>The tab stops are hardcoded to be every eighth column to meet historical practice. No new method of specifying other tab stops
    193 was invented.</p>
    194 </blockquote>
    195 <h4 class="mansect"><a name="tag_20_48_19" id="tag_20_48_19"></a>FUTURE DIRECTIONS</h4>
    196 <blockquote>
    197 <p>None.</p>
    198 </blockquote>
    199 <h4 class="mansect"><a name="tag_20_48_20" id="tag_20_48_20"></a>SEE ALSO</h4>
    200 <blockquote>
    201 <p><a href="../utilities/cut.html#"><i>cut</i></a></p>
    202 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    203 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    204 </blockquote>
    205 <h4 class="mansect"><a name="tag_20_48_21" id="tag_20_48_21"></a>CHANGE HISTORY</h4>
    206 <blockquote>
    207 <p>First released in Issue 4.</p>
    208 </blockquote>
    209 <h4 class="mansect"><a name="tag_20_48_22" id="tag_20_48_22"></a>Issue 6</h4>
    210 <blockquote>
    211 <p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p>
    212 </blockquote>
    213 <h4 class="mansect"><a name="tag_20_48_23" id="tag_20_48_23"></a>Issue 7</h4>
    214 <blockquote>
    215 <p>Austin Group Interpretation 1003.1-2001 #092 is applied.<br></p>
    216 <p>Austin Group Interpretation 1003.1-2001 #204 is applied, updating the DESCRIPTION to clarify when a &lt;newline&gt; can be
    217 inserted before or after a &lt;backspace&gt;.</p>
    218 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    219 </blockquote>
    220 <h4 class="mansect"><a name="tag_20_48_24" id="tag_20_48_24"></a>Issue 8</h4>
    221 <blockquote>
    222 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    223 </blockquote>
    224 <div class="box"><em>End of informative text.</em></div>
    225 <hr>
    226 <p>&nbsp;</p>
    227 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    228 <hr size="2" noshade>
    229 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    230 POSIX™ is a Trademark of The IEEE.<br>
    231 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    232 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    233 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    234 ]</font></center>
    235 <hr size="2" noshade>
    236 <div class="NAVHEADER">
    237 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    238 <tr class="nav">
    239 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/find.html" accesskey="P">&lt;&lt;&lt;
    240 Previous</a></td>
    241 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    242 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/fuser.html" accesskey="N">Next
    243 &gt;&gt;&gt;</a></td>
    244 </tr>
    245 </table>
    246 <hr align="left" width="100%"></div>
    247 </body>
    248 </html>