Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
comm.html (14581B)
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>comm</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/cmp.html" accesskey="P"><<< 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/command.html" accesskey="N">Next 19 >>></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="comm" id="comm"></a> <a name="tag_20_21" id="tag_20_21"></a><!-- comm --> 29 <h4 class="mansect"><a name="tag_20_21_01" id="tag_20_21_01"></a>NAME</h4> 30 <blockquote>comm — select or reject lines common to two files</blockquote> 31 <h4 class="mansect"><a name="tag_20_21_02" id="tag_20_21_02"></a>SYNOPSIS</h4> 32 <blockquote class="synopsis"> 33 <p><code><tt>comm</tt> <b>[</b><tt>-123</tt><b>]</b> <i>file1 file2</i></code></p> 34 </blockquote> 35 <h4 class="mansect"><a name="tag_20_21_03" id="tag_20_21_03"></a>DESCRIPTION</h4> 36 <blockquote> 37 <p>The <i>comm</i> utility shall read <i>file1</i> and <i>file2</i>, which should be ordered in the current collating sequence, and 38 produce three text columns as output: lines only in <i>file1</i>, lines only in <i>file2</i>, and lines in both files.</p> 39 <p>If the lines in both files are not ordered according to the collating sequence of the current locale, the results are 40 unspecified.</p> 41 <p>If the collating sequence of the current locale does not have a total ordering of all characters (see XBD <a href= 42 "../basedefs/V1_chap07.html#tag_07_03_02"><i>7.3.2 LC_COLLATE</i></a> ) and any lines from the input files collate equally but are 43 not identical, <i>comm</i> shall treat them as different lines and shall expect them to be ordered according to a further 44 byte-by-byte comparison using the collating sequence for the POSIX locale; if they are not ordered in this way, the output of 45 <i>comm</i> can identify such lines as being both unique to <i>file1</i> and unique to <i>file2</i> instead of being in both 46 files.</p> 47 </blockquote> 48 <h4 class="mansect"><a name="tag_20_21_04" id="tag_20_21_04"></a>OPTIONS</h4> 49 <blockquote> 50 <p>The <i>comm</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 51 Guidelines</i></a> .</p> 52 <p>The following options shall be supported:</p> 53 <dl compact> 54 <dd></dd> 55 <dt><b>-1</b></dt> 56 <dd>Suppress the output column of lines unique to <i>file1</i>.</dd> 57 <dt><b>-2</b></dt> 58 <dd>Suppress the output column of lines unique to <i>file2</i>.</dd> 59 <dt><b>-3</b></dt> 60 <dd>Suppress the output column of lines duplicated in <i>file1</i> and <i>file2</i>.</dd> 61 </dl> 62 </blockquote> 63 <h4 class="mansect"><a name="tag_20_21_05" id="tag_20_21_05"></a>OPERANDS</h4> 64 <blockquote> 65 <p>The following operands shall be supported:</p> 66 <dl compact> 67 <dd></dd> 68 <dt><i>file1</i></dt> 69 <dd>A pathname of the first file to be compared. If <i>file1</i> is <tt>'-'</tt>, the standard input shall be used.</dd> 70 <dt><i>file2</i></dt> 71 <dd>A pathname of the second file to be compared. If <i>file2</i> is <tt>'-'</tt>, the standard input shall be used.</dd> 72 </dl> 73 <p>If both <i>file1</i> and <i>file2</i> refer to standard input or to the same FIFO special, block special, or character special 74 file, the results are undefined.</p> 75 </blockquote> 76 <h4 class="mansect"><a name="tag_20_21_06" id="tag_20_21_06"></a>STDIN</h4> 77 <blockquote> 78 <p>The standard input shall be used only if one of the <i>file1</i> or <i>file2</i> operands refers to standard input. See the 79 INPUT FILES section.</p> 80 </blockquote> 81 <h4 class="mansect"><a name="tag_20_21_07" id="tag_20_21_07"></a>INPUT FILES</h4> 82 <blockquote> 83 <p>The input files shall be text files.</p> 84 </blockquote> 85 <h4 class="mansect"><a name="tag_20_21_08" id="tag_20_21_08"></a>ENVIRONMENT VARIABLES</h4> 86 <blockquote> 87 <p>The following environment variables shall affect the execution of <i>comm</i>:</p> 88 <dl compact> 89 <dd></dd> 90 <dt><i>LANG</i></dt> 91 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 92 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 93 variables used to determine the values of locale categories.)</dd> 94 <dt><i>LC_ALL</i></dt> 95 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 96 <dt><i>LC_COLLATE</i></dt> 97 <dd><br> 98 Determine the locale for the collating sequence <i>comm</i> expects to have been used when the input files were sorted.</dd> 99 <dt><i>LC_CTYPE</i></dt> 100 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 101 opposed to multi-byte characters in arguments and input files).</dd> 102 <dt><i>LC_MESSAGES</i></dt> 103 <dd><br> 104 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd> 105 <dt><i>NLSPATH</i></dt> 106 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 107 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 108 "0"></dd> 109 </dl> 110 </blockquote> 111 <h4 class="mansect"><a name="tag_20_21_09" id="tag_20_21_09"></a>ASYNCHRONOUS EVENTS</h4> 112 <blockquote> 113 <p>Default.</p> 114 </blockquote> 115 <h4 class="mansect"><a name="tag_20_21_10" id="tag_20_21_10"></a>STDOUT</h4> 116 <blockquote> 117 <p>The <i>comm</i> utility shall produce output depending on the options selected. If the <b>-1</b>, <b>-2</b>, and <b>-3</b> 118 options are all selected, <i>comm</i> shall write nothing to standard output.</p> 119 <p>If the <b>-1</b> option is not selected, lines contained only in <i>file1</i> shall be written using the format:</p> 120 <pre> 121 <tt>"%s\n", <</tt><i>line in file1</i><tt>> 122 </tt></pre> 123 <p>If the <b>-2</b> option is not selected, lines contained only in <i>file2</i> are written using the format:</p> 124 <pre> 125 <tt>"%s%s\n", <</tt><i>lead</i><tt>>, <</tt><i>line in file2</i><tt>> 126 </tt></pre> 127 <p>where the string <<i>lead</i>> is as follows:</p> 128 <dl compact> 129 <dd></dd> 130 <dt><tab></dt> 131 <dd>The <b>-1</b> option is not selected.</dd> 132 <dt>null string</dt> 133 <dd>The <b>-1</b> option is selected.</dd> 134 </dl> 135 <p>If the <b>-3</b> option is not selected, lines contained in both files shall be written using the format:</p> 136 <pre> 137 <tt>"%s%s\n", <</tt><i>lead</i><tt>>, <</tt><i>line in both</i><tt>> 138 </tt></pre> 139 <p>where the string <<i>lead</i>> is as follows:</p> 140 <dl compact> 141 <dd></dd> 142 <dt><tab><tab></dt> 143 <dd>Neither the <b>-1</b> nor the <b>-2</b> option is selected.</dd> 144 <dt><tab></dt> 145 <dd>Exactly one of the <b>-1</b> and <b>-2</b> options is selected.</dd> 146 <dt>null string</dt> 147 <dd>Both the <b>-1</b> and <b>-2</b> options are selected.</dd> 148 </dl> 149 <p>If the input files were ordered according to the collating sequence of the current locale, the lines written shall be in the 150 collating sequence of the current locale. If the input files contained any lines that collated equally but were not identical and 151 within each file those lines were ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX 152 locale, then lines written that collate equally but are not identical shall be ordered according to a further byte-by-byte 153 comparison using the collating sequence for the POSIX locale.</p> 154 </blockquote> 155 <h4 class="mansect"><a name="tag_20_21_11" id="tag_20_21_11"></a>STDERR</h4> 156 <blockquote> 157 <p>The standard error shall be used only for diagnostic messages.</p> 158 </blockquote> 159 <h4 class="mansect"><a name="tag_20_21_12" id="tag_20_21_12"></a>OUTPUT FILES</h4> 160 <blockquote> 161 <p>None.</p> 162 </blockquote> 163 <h4 class="mansect"><a name="tag_20_21_13" id="tag_20_21_13"></a>EXTENDED DESCRIPTION</h4> 164 <blockquote> 165 <p>None.</p> 166 </blockquote> 167 <h4 class="mansect"><a name="tag_20_21_14" id="tag_20_21_14"></a>EXIT STATUS</h4> 168 <blockquote> 169 <p>The following exit values shall be returned:</p> 170 <dl compact> 171 <dd></dd> 172 <dt> 0</dt> 173 <dd>All input files were successfully output as specified.</dd> 174 <dt>>0</dt> 175 <dd>An error occurred.</dd> 176 </dl> 177 </blockquote> 178 <h4 class="mansect"><a name="tag_20_21_15" id="tag_20_21_15"></a>CONSEQUENCES OF ERRORS</h4> 179 <blockquote> 180 <p>Default.</p> 181 </blockquote> 182 <hr> 183 <div class="box"><em>The following sections are informative.</em></div> 184 <h4 class="mansect"><a name="tag_20_21_16" id="tag_20_21_16"></a>APPLICATION USAGE</h4> 185 <blockquote> 186 <p>If the input files are not properly presorted, the output of <i>comm</i> might not be useful.</p> 187 <p>When using <i>comm</i> to process pathnames, it is recommended that LC_ALL, or at least LC_CTYPE and LC_COLLATE, are set to 188 POSIX or C in the environment, since pathnames can contain byte sequences that do not form valid characters in some locales, in 189 which case the utility's behavior would be undefined. In the POSIX locale each byte is a valid single-byte character, and therefore 190 this problem is avoided.</p> 191 <p>If the collating sequence of the current locale does not have a total ordering of all characters, since <i>comm</i> treats lines 192 as being the same only if they are identical, some lines can be misleadingly identified as being both unique to <i>file1</i> and 193 unique to <i>file2</i> if lines that collate equally but are not identical are not ordered in the way that <i>comm</i> expects. If 194 the input does not come from utilities (such as <a href="../utilities/ls.html"><i>ls</i></a> and <a href= 195 "../utilities/sort.html"><i>sort</i></a>) which provide this ordering, the problem can be avoided by pre-sorting the input files 196 using <a href="../utilities/sort.html"><i>sort</i></a>.</p> 197 </blockquote> 198 <h4 class="mansect"><a name="tag_20_21_17" id="tag_20_21_17"></a>EXAMPLES</h4> 199 <blockquote> 200 <p>If a file named <b>xcu</b> contains a sorted list of the utilities in this volume of POSIX.1-2024, a file named <b>xpg3</b> 201 contains a sorted list of the utilities specified in the X/Open Portability Guide, Issue 3, and a file named <b>svid89</b> contains 202 a sorted list of the utilities in the System V Interface Definition Third Edition:</p> 203 <pre> 204 <tt>comm -23 xcu xpg3 | comm -23 - svid89 205 </tt></pre> 206 <p>would print a list of utilities in this volume of POSIX.1-2024 not specified by either of the other documents:</p> 207 <pre> 208 <tt>comm -12 xcu xpg3 | comm -12 - svid89 209 </tt></pre> 210 <p>would print a list of utilities specified by all three documents, and:</p> 211 <pre> 212 <tt>comm -12 xpg3 svid89 | comm -23 - xcu 213 </tt></pre> 214 <p>would print a list of utilities specified by both XPG3 and the SVID, but not specified in this volume of POSIX.1-2024.</p> 215 </blockquote> 216 <h4 class="mansect"><a name="tag_20_21_18" id="tag_20_21_18"></a>RATIONALE</h4> 217 <blockquote> 218 <p>None.</p> 219 </blockquote> 220 <h4 class="mansect"><a name="tag_20_21_19" id="tag_20_21_19"></a>FUTURE DIRECTIONS</h4> 221 <blockquote> 222 <p>None.</p> 223 </blockquote> 224 <h4 class="mansect"><a name="tag_20_21_20" id="tag_20_21_20"></a>SEE ALSO</h4> 225 <blockquote> 226 <p><a href="../utilities/cmp.html#"><i>cmp</i></a> , <a href="../utilities/diff.html#"><i>diff</i></a> , <a href= 227 "../utilities/sort.html#"><i>sort</i></a> , <a href="../utilities/uniq.html#"><i>uniq</i></a></p> 228 <p>XBD <a href="../basedefs/V1_chap07.html#tag_07_03_02"><i>7.3.2 LC_COLLATE</i></a> , <a href= 229 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 230 Utility Syntax Guidelines</i></a></p> 231 </blockquote> 232 <h4 class="mansect"><a name="tag_20_21_21" id="tag_20_21_21"></a>CHANGE HISTORY</h4> 233 <blockquote> 234 <p>First released in Issue 2.</p> 235 </blockquote> 236 <h4 class="mansect"><a name="tag_20_21_22" id="tag_20_21_22"></a>Issue 6</h4> 237 <blockquote> 238 <p>The normative text is reworded to avoid use of the term "must" for application requirements.</p> 239 </blockquote> 240 <h4 class="mansect"><a name="tag_20_21_23" id="tag_20_21_23"></a>Issue 7</h4> 241 <blockquote> 242 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0076 [963], XCU/TC2-2008/0077 [663], and XCU/TC2-2008/0078 [963] are 243 applied.</p> 244 </blockquote> 245 <h4 class="mansect"><a name="tag_20_21_24" id="tag_20_21_24"></a>Issue 8</h4> 246 <blockquote> 247 <p>Austin Group Defect 1070 is applied, changing the requirements when any lines from the input files collate equally but are not 248 identical.</p> 249 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 250 </blockquote> 251 <div class="box"><em>End of informative text.</em></div> 252 <hr> 253 <p> </p> 254 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 255 <hr size="2" noshade> 256 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 257 POSIX™ is a Trademark of The IEEE.<br> 258 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 259 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 260 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 261 ]</font></center> 262 <hr size="2" noshade> 263 <div class="NAVHEADER"> 264 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 265 <tr class="nav"> 266 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/cmp.html" accesskey="P"><<< 267 Previous</a></td> 268 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 269 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/command.html" accesskey="N">Next 270 >>></a></td> 271 </tr> 272 </table> 273 <hr align="left" width="100%"></div> 274 </body> 275 </html>