{
    "mode": "info",
    "parameter": "comm",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/comm/json",
    "generated": "2026-07-30T21:44:35Z",
    "sections": {
        "File: coreutils.info,  Node: comm invocation,  Next: ptx invocation,  Prev: uniq invocation,  Up: Operating on sorted files": {
            "content": "",
            "subsections": [
                {
                    "name": "7.4 'comm': Compare two sorted files line by line",
                    "content": "'comm' writes to standard output lines that are common, and lines that\nare unique, to two input files; a file name of '-' means standard input.\nSynopsis:\n\ncomm [OPTION]... FILE1 FILE2\n\nBefore 'comm' can be used, the input files must be sorted using the\ncollating sequence specified by the 'LCCOLLATE' locale.  If an input\nfile ends in a non-newline character, a newline is silently appended."
                }
            ]
        },
        "The 'sort' command with no options always outputs a file that is": {
            "content": "suitable input to 'comm'.\n\nWith no options, 'comm' produces three-column output.  Column one\ncontains lines unique to FILE1, column two contains lines unique to\nFILE2, and column three contains lines common to both files.  Columns\nare separated by a single TAB character.\n\nThe options '-1', '-2', and '-3' suppress printing of the\ncorresponding columns (and separators).  Also see *note Common\noptions::.\n\nUnlike some other comparison utilities, 'comm' has an exit status\nthat does not depend on the result of the comparison.  Upon normal\ncompletion 'comm' produces an exit code of zero.  If there is an error\nit exits with nonzero status.\n\nIf the '--check-order' option is given, unsorted inputs will cause a\nfatal error message.  If the option '--nocheck-order' is given, unsorted\ninputs will never cause an error message.  If neither of these options\nis given, wrongly sorted inputs are diagnosed only if an input file is\nfound to contain unpairable lines.  If an input file is diagnosed as\nbeing unsorted, the 'comm' command will exit with a nonzero status (and\nthe output should not be used).\n\nForcing 'comm' to process wrongly sorted input files containing\nunpairable lines by specifying '--nocheck-order' is not guaranteed to\nproduce any particular output.  The output will probably not correspond\nwith whatever you hoped it would be.\n\n'--check-order'\nFail with an error message if either input file is wrongly ordered.\n\n'--nocheck-order'\nDo not check that both input files are in sorted order.\n\nOther options are:\n\n'--output-delimiter=STR'\nPrint STR between adjacent output columns, rather than the default\nof a single TAB character.\n\nThe delimiter STR may not be empty.\n\n'--total'\nOutput a summary at the end.\n\nSimilar to the regular output, column one contains the total number\nof lines unique to FILE1, column two contains the total number of\nlines unique to FILE2, and column three contains the total number\nof lines common to both files, followed by the word 'total' in the\nadditional column four.\n\nIn the following example, 'comm' omits the regular output ('-123'),\nthus just printing the summary:\n\n$ printf '%s\\n' a b c d e     > file1\n$ printf '%s\\n'   b c d e f g > file2\n$ comm --total -123 file1 file2\n1       2       4       total\n\nThis option is a GNU extension.  Portable scripts should use 'wc'\nto get the totals, e.g.  for the above example files:\n\n$ comm -23 file1 file2 | wc -l    # number of lines only in file1\n1\n$ comm -13 file1 file2 | wc -l    # number of lines only in file2\n2\n$ comm -12 file1 file2 | wc -l    # number of lines common to both files\n4\n\n'-z'\n'--zero-terminated'\nDelimit items with a zero byte rather than a newline (ASCII LF).\nI.e., treat input as items separated by ASCII NUL and terminate\noutput items with ASCII NUL. This option can be useful in\nconjunction with 'perl -0' or 'find -print0' and 'xargs -0' which\ndo the same in order to reliably handle arbitrary file names (even\nthose containing blanks or other special characters).\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}