logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

comm.1p (10519B)


  1. '\" et
  2. .TH COMM "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. comm
  12. \(em select or reject lines common to two files
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. comm \fB[\fR-123\fB] \fIfile1 file2\fR
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR comm
  21. utility shall read
  22. .IR file1
  23. and
  24. .IR file2 ,
  25. which should be ordered in the current collating sequence, and produce
  26. three text columns as output: lines only in
  27. .IR file1 ,
  28. lines only in
  29. .IR file2 ,
  30. and lines in both files.
  31. .P
  32. If the lines in both files are not ordered according to the collating
  33. sequence of the current locale, the results are unspecified.
  34. .P
  35. If the collating sequence of the current locale does not have a total
  36. ordering of all characters (see the Base Definitions volume of POSIX.1\(hy2017,
  37. .IR "Section 7.3.2" ", " "LC_COLLATE")
  38. and any lines from the input files collate equally but are not identical,
  39. .IR comm
  40. should treat them as different lines but may treat them as being the
  41. same. If it treats them as different,
  42. .IR comm
  43. should expect them to be ordered according to a further byte-by-byte
  44. comparison using the collating sequence for the POSIX locale and if
  45. they are not ordered in this way, the output of
  46. .IR comm
  47. can identify such lines as being both unique to
  48. .IR file1
  49. and unique to
  50. .IR file2
  51. instead of being in both files.
  52. .SH OPTIONS
  53. The
  54. .IR comm
  55. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  56. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  57. .P
  58. The following options shall be supported:
  59. .IP "\fB\-1\fP" 10
  60. Suppress the output column of lines unique to
  61. .IR file1 .
  62. .IP "\fB\-2\fP" 10
  63. Suppress the output column of lines unique to
  64. .IR file2 .
  65. .IP "\fB\-3\fP" 10
  66. Suppress the output column of lines duplicated in
  67. .IR file1
  68. and
  69. .IR file2 .
  70. .SH OPERANDS
  71. The following operands shall be supported:
  72. .IP "\fIfile1\fR" 10
  73. A pathname of the first file to be compared. If
  74. .IR file1
  75. is
  76. .BR '\-' ,
  77. the standard input shall be used.
  78. .IP "\fIfile2\fR" 10
  79. A pathname of the second file to be compared. If
  80. .IR file2
  81. is
  82. .BR '\-' ,
  83. the standard input shall be used.
  84. .P
  85. If both
  86. .IR file1
  87. and
  88. .IR file2
  89. refer to standard input or to the same FIFO special, block special, or
  90. character special file, the results are undefined.
  91. .SH STDIN
  92. The standard input shall be used only if one of the
  93. .IR file1
  94. or
  95. .IR file2
  96. operands refers to standard input. See the INPUT FILES section.
  97. .SH "INPUT FILES"
  98. The input files shall be text files.
  99. .SH "ENVIRONMENT VARIABLES"
  100. The following environment variables shall affect the execution of
  101. .IR comm :
  102. .IP "\fILANG\fP" 10
  103. Provide a default value for the internationalization variables that are
  104. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  105. .IR "Section 8.2" ", " "Internationalization Variables"
  106. for the precedence of internationalization variables used to determine
  107. the values of locale categories.)
  108. .IP "\fILC_ALL\fP" 10
  109. If set to a non-empty string value, override the values of all the
  110. other internationalization variables.
  111. .IP "\fILC_COLLATE\fP" 10
  112. .br
  113. Determine the locale for the collating sequence
  114. .IR comm
  115. expects to have been used when the input files were sorted.
  116. .IP "\fILC_CTYPE\fP" 10
  117. Determine the locale for the interpretation of sequences of bytes of
  118. text data as characters (for example, single-byte as opposed to
  119. multi-byte characters in arguments and input files).
  120. .IP "\fILC_MESSAGES\fP" 10
  121. .br
  122. Determine the locale that should be used to affect the format and
  123. contents of diagnostic messages written to standard error.
  124. .IP "\fINLSPATH\fP" 10
  125. Determine the location of message catalogs for the processing of
  126. .IR LC_MESSAGES .
  127. .SH "ASYNCHRONOUS EVENTS"
  128. Default.
  129. .SH STDOUT
  130. The
  131. .IR comm
  132. utility shall produce output depending on the options selected. If the
  133. .BR \-1 ,
  134. .BR \-2 ,
  135. and
  136. .BR \-3
  137. options are all selected,
  138. .IR comm
  139. shall write nothing to standard output.
  140. .P
  141. If the
  142. .BR \-1
  143. option is not selected, lines contained only in
  144. .IR file1
  145. shall be written using the format:
  146. .sp
  147. .RS 4
  148. .nf
  149. "%s\en", <\fIline in file1\fR>
  150. .fi
  151. .P
  152. .RE
  153. .P
  154. If the
  155. .BR \-2
  156. option is not selected, lines contained only in
  157. .IR file2
  158. are written using the format:
  159. .sp
  160. .RS 4
  161. .nf
  162. "%s%s\en", <\fIlead\fR>, <\fIline in file2\fR>
  163. .fi
  164. .P
  165. .RE
  166. .P
  167. where the string <\fIlead\fP> is as follows:
  168. .IP <tab> 10
  169. The
  170. .BR \-1
  171. option is not selected.
  172. .IP "null\ string" 10
  173. The
  174. .BR \-1
  175. option is selected.
  176. .P
  177. If the
  178. .BR \-3
  179. option is not selected, lines contained in both files shall be written
  180. using the format:
  181. .sp
  182. .RS 4
  183. .nf
  184. "%s%s\en", <\fIlead\fR>, <\fIline in both\fR>
  185. .fi
  186. .P
  187. .RE
  188. .P
  189. where the string <\fIlead\fP> is as follows:
  190. .IP <tab><tab> 10
  191. Neither the
  192. .BR \-1
  193. nor the
  194. .BR \-2
  195. option is selected.
  196. .IP <tab> 10
  197. Exactly one of the
  198. .BR \-1
  199. and
  200. .BR \-2
  201. options is selected.
  202. .IP "null\ string" 10
  203. Both the
  204. .BR \-1
  205. and
  206. .BR \-2
  207. options are selected.
  208. .P
  209. If the input files were ordered according to the collating sequence of
  210. the current locale, the lines written shall be in the collating
  211. sequence of the current locale. If the input files contained any
  212. lines that collated equally but were not identical and within each
  213. file those lines were ordered according to a further byte-by-byte
  214. comparison using the collating sequence for the POSIX locale, and
  215. .IR comm
  216. treated them as different lines, then lines written that collate
  217. equally but are not identical should be ordered according to a further
  218. byte-by-byte comparison using the collating sequence for the POSIX
  219. locale.
  220. .SH STDERR
  221. The standard error shall be used only for diagnostic messages.
  222. .SH "OUTPUT FILES"
  223. None.
  224. .SH "EXTENDED DESCRIPTION"
  225. None.
  226. .SH "EXIT STATUS"
  227. The following exit values shall be returned:
  228. .IP "\00" 6
  229. All input files were successfully output as specified.
  230. .IP >0 6
  231. An error occurred.
  232. .SH "CONSEQUENCES OF ERRORS"
  233. Default.
  234. .LP
  235. .IR "The following sections are informative."
  236. .SH "APPLICATION USAGE"
  237. If the input files are not properly presorted, the output of
  238. .IR comm
  239. might not be useful.
  240. .P
  241. When using
  242. .IR comm
  243. to process pathnames, it is recommended that LC_ALL, or at least
  244. LC_CTYPE and LC_COLLATE, are set to POSIX or C in the environment,
  245. since pathnames can contain byte sequences that do not form valid
  246. characters in some locales, in which case the utility's behavior would
  247. be undefined. In the POSIX locale each byte is a valid single-byte
  248. character, and therefore this problem is avoided.
  249. .P
  250. If the collating sequence of the current locale does not have a total
  251. ordering of all characters, this can affect the behavior of
  252. .IR comm
  253. in the following ways:
  254. .IP " *" 4
  255. If
  256. .IR comm
  257. treats lines as being the same only if they are identical, some lines
  258. can be misleadingly identified as being both unique to
  259. .IR file1
  260. and unique to
  261. .IR file2 .
  262. .IP " *" 4
  263. If
  264. .IR comm
  265. treats lines as being the same if they collate equally and a line from
  266. .IR file1
  267. collates equally with a line from
  268. .IR file2
  269. but is not identical to it, one of the lines is misleadingly
  270. identified as being in both files and the other is not written to the
  271. output at all.
  272. .P
  273. Such problems can be avoided by forcing the use of the POSIX locale;
  274. for example, the following identifies lines in both
  275. .IR file1
  276. and
  277. .IR file2 :
  278. .sp
  279. .RS 4
  280. .nf
  281. LC_ALL=POSIX sort file1 > file1.posix
  282. LC_ALL=POSIX sort file2 > file2.posix
  283. LC_ALL=POSIX comm -12 file1.posix file2.posix | sort
  284. .fi
  285. .P
  286. .RE
  287. .P
  288. The final
  289. .IR sort
  290. re-sorts the output of
  291. .IR comm
  292. according to the collating sequence of the original locale. Doing
  293. this might be difficult if more than one column is output and leading
  294. <blank>s
  295. cannot be ignored.
  296. .SH EXAMPLES
  297. If a file named
  298. .BR xcu
  299. contains a sorted list of the utilities in this volume of POSIX.1\(hy2017, a file named
  300. .BR xpg3
  301. contains a sorted list of the utilities specified in the X/Open
  302. Portability Guide, Issue 3, and a file named
  303. .BR svid89
  304. contains a sorted list of the utilities in the System V Interface
  305. Definition Third Edition:
  306. .sp
  307. .RS 4
  308. .nf
  309. comm -23 xcu xpg3 | comm -23 - svid89
  310. .fi
  311. .P
  312. .RE
  313. .P
  314. would print a list of utilities in this volume of POSIX.1\(hy2017 not specified by either of the
  315. other documents:
  316. .sp
  317. .RS 4
  318. .nf
  319. comm -12 xcu xpg3 | comm -12 - svid89
  320. .fi
  321. .P
  322. .RE
  323. .P
  324. would print a list of utilities specified by all three documents, and:
  325. .sp
  326. .RS 4
  327. .nf
  328. comm -12 xpg3 svid89 | comm -23 - xcu
  329. .fi
  330. .P
  331. .RE
  332. .P
  333. would print a list of utilities specified by both XPG3 and the SVID,
  334. but not specified in this volume of POSIX.1\(hy2017.
  335. .SH RATIONALE
  336. None.
  337. .SH "FUTURE DIRECTIONS"
  338. A future version of this standard may require that if any lines from
  339. the input files collate equally but are not identical, then
  340. .IR comm
  341. treats them as different lines and expects them to be ordered
  342. according to a further byte-by-byte comparison using the collating
  343. sequence for the POSIX locale.
  344. .P
  345. A future version of this standard may require that if the input files
  346. contained any lines that collated equally but were not identical and
  347. within each file those lines were ordered according to a further
  348. byte-by-byte comparison using the collating sequence for the POSIX
  349. locale, then lines written that collate equally but are not identical
  350. are ordered according to a further byte-by-byte comparison using the
  351. collating sequence for the POSIX locale.
  352. .SH "SEE ALSO"
  353. .IR "\fIcmp\fR\^",
  354. .IR "\fIdiff\fR\^",
  355. .IR "\fIsort\fR\^",
  356. .IR "\fIuniq\fR\^"
  357. .P
  358. The Base Definitions volume of POSIX.1\(hy2017,
  359. .IR "Section 7.3.2" ", " "LC_COLLATE",
  360. .IR "Chapter 8" ", " "Environment Variables",
  361. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  362. .\"
  363. .SH COPYRIGHT
  364. Portions of this text are reprinted and reproduced in electronic form
  365. from IEEE Std 1003.1-2017, Standard for Information Technology
  366. -- Portable Operating System Interface (POSIX), The Open Group Base
  367. Specifications Issue 7, 2018 Edition,
  368. Copyright (C) 2018 by the Institute of
  369. Electrical and Electronics Engineers, Inc and The Open Group.
  370. In the event of any discrepancy between this version and the original IEEE and
  371. The Open Group Standard, the original IEEE and The Open Group Standard
  372. is the referee document. The original Standard can be obtained online at
  373. http://www.opengroup.org/unix/online.html .
  374. .PP
  375. Any typographical or formatting errors that appear
  376. in this page are most likely
  377. to have been introduced during the conversion of the source files to
  378. man page format. To report such errors, see
  379. https://www.kernel.org/doc/man-pages/reporting_bugs.html .