comm is a shell command for comparing two files for common and distinct lines. It reads the files as lines of text and outputs text as three columns. The first two columns contain lines unique to the first and second file, respectively. The last column contains lines common to both. Columns are typically separated with the tab character. If the input text contains lines beginning with the separator character, the output columns can become ambiguous.
via Wikipedia infobox
~4 min read
comm is a shell command for comparing two files for common and distinct lines. It reads the files as lines of text and outputs text as three columns. The first two columns contain lines unique to the first and second file, respectively. The last column contains lines common to both. Columns are typically separated with the tab character. If the input text contains lines beginning with the separator character, the output columns can become ambiguous.
For efficiency, standard implementations of expect both input files to be sequenced in the same line collation order, sorted lexically. The sort command can be used for this purpose. The algorithm makes use of the collating sequence of the current locale. If the lines in the files are not both collated in accordance with the current locale, the result is undefined.
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. If the collating sequence of the current locale does not have a total ordering of all characters (see XBD LC COLLATE ) and any lines from the input files collate equally but are not identical, comm should treat them as different lines but may treat them as being the same. If it treats them as different, comm should expect them to be ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX locale and if they are not ordered in this way, the output of comm can identify such lines as being both unique to file1 and unique to file2 instead of being in both files. Suppress the output column of lines duplicated in file1 and file2 . 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. The standard input shall be used only if one of the file1 or file2 operands refers to standard input. See the INPUT FILES section. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale for the collating sequence comm expects to have been used when the input files were sorted. Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files). Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( 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 current locale. If the input files contained any lines that collated equally but were not identical and within each file those lines were ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX locale, and comm treated them as different lines, then lines written that collate equally but are not identical should be ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX locale. If the input files are not properly presorted, the output of comm might not be useful. LC ALL=POSIX sort file1 file1.posix LC ALL=POSIX sort file2 file2.posix LC ALL=POSIX comm -12 file1.posix file2.posix sort The final sort re-sorts the output of comm according to the collating sequence of the original locale. Doing this might be difficult if more than one column is output and leading s cannot be ignored. would print a list of utilities specified by both XPG3 and the SVID, but not specified in this volume of POSIX.1-2017. A future version of this standard may require that if any lines from the input files collate equally but are not identical, then comm treats them as different lines and expects them to be ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX locale. A future version of this standard may require that if the input files contained any lines that collated equally but were not identical and within each file those lines were ordered according to a further byte-by-byte comparison using the collating sequence for the POSIX locale, then lines written that collate equally but are not identical are ordered according
Excerpt from a page describing this subject · 11,774 chars · not written by Vinony
via Wikidata · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).