isposix

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

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

cat.html (13128B)


      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>cat</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/cal.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/cd.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
     19 </tr>
     20 </table>
     21 <hr align="left" width="100%"></div>
     22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     23 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     24 IEEE Std 1003.1-2024<br>
     25 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     26 <hr size="2" noshade>
     27 <a name="top" id="top"></a> <a name="cat" id="cat"></a> <a name="tag_20_13" id="tag_20_13"></a><!-- cat -->
     28 <h4 class="mansect"><a name="tag_20_13_01" id="tag_20_13_01"></a>NAME</h4>
     29 <blockquote>cat — concatenate and print files</blockquote>
     30 <h4 class="mansect"><a name="tag_20_13_02" id="tag_20_13_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <p><code><tt>cat</tt> <b>[</b><tt>-u</tt><b>] [</b><i>file</i><tt>...</tt><b>]</b></code></p>
     33 </blockquote>
     34 <h4 class="mansect"><a name="tag_20_13_03" id="tag_20_13_03"></a>DESCRIPTION</h4>
     35 <blockquote>
     36 <p>The <i>cat</i> utility shall read files in sequence and shall write their contents to the standard output in the same
     37 sequence.</p>
     38 </blockquote>
     39 <h4 class="mansect"><a name="tag_20_13_04" id="tag_20_13_04"></a>OPTIONS</h4>
     40 <blockquote>
     41 <p>The <i>cat</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     42 Guidelines</i></a> .</p>
     43 <p>The following option shall be supported:</p>
     44 <dl compact>
     45 <dd></dd>
     46 <dt><b>-u</b></dt>
     47 <dd>Write bytes from the input file to the standard output without delay as each is read.</dd>
     48 </dl>
     49 </blockquote>
     50 <h4 class="mansect"><a name="tag_20_13_05" id="tag_20_13_05"></a>OPERANDS</h4>
     51 <blockquote>
     52 <p>The following operand shall be supported:</p>
     53 <dl compact>
     54 <dd></dd>
     55 <dt><i>file</i></dt>
     56 <dd>A pathname of an input file. If no <i>file</i> operands are specified, the standard input shall be used. If a <i>file</i> is
     57 <tt>'-'</tt>, the <i>cat</i> utility shall read from the standard input at that point in the sequence. The <i>cat</i> utility shall
     58 not close and reopen standard input when it is referenced in this way, but shall accept multiple occurrences of <tt>'-'</tt> as a
     59 <i>file</i> operand.</dd>
     60 </dl>
     61 </blockquote>
     62 <h4 class="mansect"><a name="tag_20_13_06" id="tag_20_13_06"></a>STDIN</h4>
     63 <blockquote>
     64 <p>The standard input shall be used only if no <i>file</i> operands are specified, or if a <i>file</i> operand is <tt>'-'</tt>. See
     65 the INPUT FILES section.</p>
     66 </blockquote>
     67 <h4 class="mansect"><a name="tag_20_13_07" id="tag_20_13_07"></a>INPUT FILES</h4>
     68 <blockquote>
     69 <p>The input files can be any file type.</p>
     70 </blockquote>
     71 <h4 class="mansect"><a name="tag_20_13_08" id="tag_20_13_08"></a>ENVIRONMENT VARIABLES</h4>
     72 <blockquote>
     73 <p>The following environment variables shall affect the execution of <i>cat</i>:</p>
     74 <dl compact>
     75 <dd></dd>
     76 <dt><i>LANG</i></dt>
     77 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
     78 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
     79 variables used to determine the values of locale categories.)</dd>
     80 <dt><i>LC_ALL</i></dt>
     81 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
     82 <dt><i>LC_CTYPE</i></dt>
     83 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
     84 opposed to multi-byte characters in arguments).</dd>
     85 <dt><i>LC_MESSAGES</i></dt>
     86 <dd><br>
     87 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
     88 <dt><i>NLSPATH</i></dt>
     89 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
     90 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
     91 "0"></dd>
     92 </dl>
     93 </blockquote>
     94 <h4 class="mansect"><a name="tag_20_13_09" id="tag_20_13_09"></a>ASYNCHRONOUS EVENTS</h4>
     95 <blockquote>
     96 <p>Default.</p>
     97 </blockquote>
     98 <h4 class="mansect"><a name="tag_20_13_10" id="tag_20_13_10"></a>STDOUT</h4>
     99 <blockquote>
    100 <p>The standard output shall contain the sequence of bytes read from the input files. Nothing else shall be written to the standard
    101 output. If the standard output is a regular file, and is the same file as any of the input file operands, the implementation may
    102 treat this as an error.</p>
    103 </blockquote>
    104 <h4 class="mansect"><a name="tag_20_13_11" id="tag_20_13_11"></a>STDERR</h4>
    105 <blockquote>
    106 <p>The standard error shall be used only for diagnostic messages.</p>
    107 </blockquote>
    108 <h4 class="mansect"><a name="tag_20_13_12" id="tag_20_13_12"></a>OUTPUT FILES</h4>
    109 <blockquote>
    110 <p>None.</p>
    111 </blockquote>
    112 <h4 class="mansect"><a name="tag_20_13_13" id="tag_20_13_13"></a>EXTENDED DESCRIPTION</h4>
    113 <blockquote>
    114 <p>None.</p>
    115 </blockquote>
    116 <h4 class="mansect"><a name="tag_20_13_14" id="tag_20_13_14"></a>EXIT STATUS</h4>
    117 <blockquote>
    118 <p>The following exit values shall be returned:</p>
    119 <dl compact>
    120 <dd></dd>
    121 <dt>&nbsp;0</dt>
    122 <dd>All input files were output successfully.</dd>
    123 <dt>&gt;0</dt>
    124 <dd>An error occurred.</dd>
    125 </dl>
    126 </blockquote>
    127 <h4 class="mansect"><a name="tag_20_13_15" id="tag_20_13_15"></a>CONSEQUENCES OF ERRORS</h4>
    128 <blockquote>
    129 <p>Default.</p>
    130 </blockquote>
    131 <hr>
    132 <div class="box"><em>The following sections are informative.</em></div>
    133 <h4 class="mansect"><a name="tag_20_13_16" id="tag_20_13_16"></a>APPLICATION USAGE</h4>
    134 <blockquote>
    135 <p>The <b>-u</b> option has value in prototyping non-blocking reads from FIFOs. The intent is to support the following
    136 sequence:</p>
    137 <pre>
    138 <tt>mkfifo foo
    139 cat -u foo &gt; /dev/tty13 &
    140 cat -u &gt; foo
    141 </tt></pre>
    142 <p>It is unspecified whether standard output is or is not buffered in the default case. This is sometimes of interest when standard
    143 output is associated with a terminal, since buffering may delay the output. The presence of the <b>-u</b> option guarantees that
    144 unbuffered I/O is available. It is implementation-defined whether the <i>cat</i> utility buffers output if the <b>-u</b> option is
    145 not specified. Traditionally, the <b>-u</b> option is implemented using the equivalent of the <a href=
    146 "../functions/setvbuf.html"><i>setvbuf</i>()</a> function defined in the System Interfaces volume of POSIX.1-2024.</p>
    147 </blockquote>
    148 <h4 class="mansect"><a name="tag_20_13_17" id="tag_20_13_17"></a>EXAMPLES</h4>
    149 <blockquote>
    150 <p>The following command:</p>
    151 <pre>
    152 <tt>cat myfile
    153 </tt></pre>
    154 <p>writes the contents of the file <b>myfile</b> to standard output.</p>
    155 <p>The following command:</p>
    156 <pre>
    157 <tt>cat doc1 doc2 &gt; doc.all
    158 </tt></pre>
    159 <p>concatenates the files <b>doc1</b> and <b>doc2</b> and writes the result to <b>doc.all</b>.</p>
    160 <p>Because of the shell language mechanism used to perform output redirection, a command such as this:</p>
    161 <pre>
    162 <tt>cat doc doc.end &gt; doc
    163 </tt></pre>
    164 <p>causes the original data in <b>doc</b> to be lost before <i>cat</i> even begins execution. This is true whether the <i>cat</i>
    165 command fails with an error or silently succeeds (the specification allows both behaviors). In order to append the contents of
    166 <b>doc.end</b> without losing the original contents of <b>doc</b>, this command should be used instead:</p>
    167 <pre>
    168 <tt>cat doc.end &gt;&gt; doc
    169 </tt></pre>
    170 <p>The command:</p>
    171 <pre>
    172 <tt>cat start - middle - end &gt; file
    173 </tt></pre>
    174 <p>when standard input is a terminal, gets two arbitrary pieces of input from the terminal with a single invocation of <i>cat</i>.
    175 Note, however, that if standard input is a regular file, this would be equivalent to the command:</p>
    176 <pre>
    177 <tt>cat start - middle /dev/null end &gt; file
    178 </tt></pre>
    179 <p>because the entire contents of the file would be consumed by <i>cat</i> the first time <tt>'-'</tt> was used as a <i>file</i>
    180 operand and an end-of-file condition would be detected immediately when <tt>'-'</tt> was referenced the second time.</p>
    181 </blockquote>
    182 <h4 class="mansect"><a name="tag_20_13_18" id="tag_20_13_18"></a>RATIONALE</h4>
    183 <blockquote>
    184 <p>Historical versions of the <i>cat</i> utility include the <b>-e</b>, <b>-t</b>, and <b>-v</b>, options which permit the ends of
    185 lines, &lt;tab&gt; characters, and invisible characters, respectively, to be rendered visible in the output. The standard
    186 developers omitted these options because they provide too fine a degree of control over what is made visible, and similar output
    187 can be obtained using a command such as:</p>
    188 <pre>
    189 <tt>sed -n l pathname
    190 </tt></pre>
    191 <p>The latter also has the advantage that its output is unambiguous, whereas the output of historical <i>cat</i> <b>-etv</b> is
    192 not.</p>
    193 <p>The <b>-s</b> option was omitted because it corresponds to different functions in BSD and System V-based systems. The BSD
    194 <b>-s</b> option to squeeze blank lines can be accomplished by the shell script shown in the following example:</p>
    195 <pre>
    196 <tt>sed -n '
    197 # Write non-empty lines.
    198 /./   {
    199       p
    200       d
    201       }
    202 # Write a single empty line, then look for more empty lines.
    203 /^$/  p
    204 # Get next line, discard the held &lt;newline&gt; (empty line),
    205 # and look for more empty lines.
    206 :Empty
    207 /^$/  {
    208       N
    209       s/.//
    210       b Empty
    211       }
    212 # Write the non-empty line before going back to search
    213 # for the first in a set of empty lines.
    214       p
    215 '
    216 </tt></pre>
    217 <p>The System V <b>-s</b> option to silence error messages can be accomplished by redirecting the standard error. Note that the BSD
    218 documentation for <i>cat</i> uses the term &quot;blank line&quot; to mean the same as the POSIX &quot;empty line&quot;: a line consisting only of a
    219 &lt;newline&gt;.</p>
    220 <p>The BSD <b>-n</b> option was omitted because similar functionality can be obtained from the <b>-n</b> option of the <a href=
    221 "../utilities/pr.html"><i>pr</i></a> utility.</p>
    222 </blockquote>
    223 <h4 class="mansect"><a name="tag_20_13_19" id="tag_20_13_19"></a>FUTURE DIRECTIONS</h4>
    224 <blockquote>
    225 <p>None.</p>
    226 </blockquote>
    227 <h4 class="mansect"><a name="tag_20_13_20" id="tag_20_13_20"></a>SEE ALSO</h4>
    228 <blockquote>
    229 <p><a href="../utilities/more.html#"><i>more</i></a></p>
    230 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    231 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    232 <p>XSH <a href="../functions/setvbuf.html#"><i>setvbuf</i></a></p>
    233 </blockquote>
    234 <h4 class="mansect"><a name="tag_20_13_21" id="tag_20_13_21"></a>CHANGE HISTORY</h4>
    235 <blockquote>
    236 <p>First released in Issue 2.</p>
    237 </blockquote>
    238 <h4 class="mansect"><a name="tag_20_13_22" id="tag_20_13_22"></a>Issue 7</h4>
    239 <blockquote>
    240 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    241 <p>SD5-XCU-ERN-174 is applied, changing the RATIONALE.</p>
    242 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0073 [876] is applied.</p>
    243 </blockquote>
    244 <h4 class="mansect"><a name="tag_20_13_23" id="tag_20_13_23"></a>Issue 8</h4>
    245 <blockquote>
    246 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    247 </blockquote>
    248 <div class="box"><em>End of informative text.</em></div>
    249 <hr>
    250 <p>&nbsp;</p>
    251 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    252 <hr size="2" noshade>
    253 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    254 POSIX™ is a Trademark of The IEEE.<br>
    255 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    256 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    257 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    258 ]</font></center>
    259 <hr size="2" noshade>
    260 <div class="NAVHEADER">
    261 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    262 <tr class="nav">
    263 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/cal.html" accesskey="P">&lt;&lt;&lt;
    264 Previous</a></td>
    265 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    266 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/cd.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
    267 </tr>
    268 </table>
    269 <hr align="left" width="100%"></div>
    270 </body>
    271 </html>