On this page you find all important commands for the CLI tool comm. If the
command you are looking for is missing please ask our AI.
comm
The comm
command is a command-line tool used to compare two sorted text files, line by line. It outputs three columns: lines only in the first file, lines only in the second file, and lines present in both files.
Here's the basic syntax:
comm [OPTION]... FILE1 FILE2
FILE1
andFILE2
are the two input text files to be compared.- By default,
comm
assumes that input files are sorted in ASCII order. If not, the results might be incorrect, so it's crucial to sort the files before usingcomm
. - The following options are available to modify the behavior of
comm
:-1
: Suppress printing lines unique to the first file.-2
: Suppress printing lines unique to the second file.-3
: Suppress printing lines that appear in both files.-i
: Ignore case differences in comparisons.-u
: Output only unique lines (excluding common lines).-z
: Use a NULL character as the output field separator.
This tool is commonly used to identify similarities and differences between two files, especially when analyzing and comparing large datasets or documenting changes between different versions of files.
List of commands for comm:
-
comm:tldr:8c6ed comm: Print lines only found in second file, when the files aren't sorted.$ comm -13 <(sort ${file1}) <(sort ${file2})try on your machineexplain this command
-
comm:tldr:900ee comm: Produce three tab-separated columns: lines only in first file, lines only in second file and common lines.$ comm ${file1} ${file2}try on your machineexplain this command
-
comm:tldr:905d2 comm: Get lines only found in first file, saving the result to a third file.$ comm -23 ${file1} ${file2} > ${file1_only}try on your machineexplain this command
-
comm:tldr:f33d6 comm: Print only lines common to both files.$ comm -12 ${file1} ${file2}try on your machineexplain this command