NAME
comm — select or
reject lines common to two files
SYNOPSIS
comm |
[-123] file1
file2 |
DESCRIPTION
The comm utility shall read file1 and
file2, which should be ordered in the current collating sequence, and
produce three text columns as output: lines only in file1; lines only in
file2; and lines in both files. If the lines in both files are not ordered
according to the collating sequence of the current locale, the results are
unspecified.
OPTIONS
The comm utility shall conform to the
utility argument syntax guidelines described in 2.10.2. The following
options shall be supported by the implementation:
OPERANDS
The following operands shall be supported by the implementation:
- file1
-
A pathname of the first file to be compared. If file1 is −, the standard input is used.
- file2
-
A pathname of the second file to be compared. If file2 is −, the standard input is used. If both file1 and file2 refer to standard input or to the same FIFO special, block special, or character special file, the results are undefined.
STANDARD INPUT
The standard input shall be used only if one of the file1 or file2 operands refers to standard input. See Input Files.
INPUT FILES
The input files shall be text files.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
comm:
LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_CTYPE-
This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments and input files).
LC_COLLATE-
This variable shall determine the locale for the collating sequence
commexpects to have been used when the input files were sorted. LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
Default.
STANDARD OUTPUT
The comm utility shall produce output
depending on the options selected. If the −1, −2, and
−3 options are all selected, comm shall write
nothing to standard output. If the −1 option is not selected, lines
contained only in file1 shall be written using the format: "%s\n",
<line in file1> If the −2 option is not selected, lines
contained only in file2 shall be written using the format:
"%s%s\n", <lead>, <line in file2> where the string
<lead> is: <tab> if the −1 option is not selected, or
null string if the −1 option is selected. If the −3 option is
not selected, lines contained in both files shall be written using the
format: "%s%s\n", <lead>, <line in both> where the
string <lead> is: <tab><tab> if neither the −1 nor
the −2 option is selected, or <tab> if exactly one of the
−1 and −2 options is selected, or null string if both the
−1 and −2 options are selected. If the input files were
ordered according to the collating sequence of the current locale, the lines
written shall be in the collating sequence of the original lines.
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The comm utility shall exit with one of
the following values:
CONSEQUENCES OF ERRORS
Default.
RATIONALE
EXAMPLES
If the input files are not properly presorted, the output of
comm might not be useful. If a file named posix.2
contains a sorted list of the utilities in this standard, a file named xpg3
contains a sorted list of the utilities specified in X/Open Portability
Guide Issue 3, and a file named svid89 contains a sorted list of the
utilities in the System V Interface Definition Third Edition:
comm -23 posix.2 xpg3 | comm
-23 - svid89 would print a list of utilities in this standard not specified
by either of the other documents, comm -12 posix.2
xpg3 | comm -12 - svid89 would print a list of
utilities specified by all three documents, and comm
-12 xpg3 svid89 | comm -23 - posix.2 would print a
list of utilities specified by both
XPG3 and
SVID, but
not specified in this standard.
HISTORY OF DECISIONS MADE
None.