{
    "mode": "man",
    "parameter": "COMM",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/COMM/1/json",
    "generated": "2026-06-14T00:46:05Z",
    "synopsis": "comm [OPTION]... FILE1 FILE2",
    "sections": {
        "NAME": {
            "content": "comm - compare two sorted files line by line\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "comm [OPTION]... FILE1 FILE2\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Compare sorted files FILE1 and FILE2 line by line.\n\nWhen FILE1 or FILE2 (not both) is -, read standard input.\n\nWith  no  options,  produce  three-column output.  Column one contains lines unique to FILE1,\ncolumn two contains lines unique to FILE2, and column three contains  lines  common  to  both\nfiles.\n",
            "subsections": [
                {
                    "name": "-1",
                    "content": "",
                    "flag": "-1"
                },
                {
                    "name": "-2",
                    "content": "",
                    "flag": "-2"
                },
                {
                    "name": "-3",
                    "content": "",
                    "flag": "-3"
                },
                {
                    "name": "--check-order",
                    "content": "check that the input is correctly sorted, even if all input lines are pairable\n",
                    "long": "--check-order"
                },
                {
                    "name": "--nocheck-order",
                    "content": "do not check that the input is correctly sorted\n\n--output-delimiter=STR\nseparate columns with STR\n",
                    "long": "--nocheck-order"
                },
                {
                    "name": "--total",
                    "content": "output a summary\n",
                    "long": "--total"
                },
                {
                    "name": "-z --zero-terminated",
                    "content": "line delimiter is NUL, not newline\n\n--help display this help and exit\n",
                    "flag": "-z",
                    "long": "--zero-terminated"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n\nNote, comparisons honor the rules specified by 'LCCOLLATE'.\n",
                    "long": "--version"
                }
            ]
        },
        "EXAMPLES": {
            "content": "comm -12 file1 file2\nPrint only lines present in both file1 and file2.\n\ncomm -3 file1 file2\nPrint lines in file1 not in file2, and vice versa.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Richard M. Stallman and David MacKenzie.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright  ©  2020 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later\n<https://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.  There is NO WARRANTY,  to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "join(1), uniq(1)\n\nFull documentation <https://www.gnu.org/software/coreutils/comm>\nor available locally via: info '(coreutils) comm invocation'\n\n\n\nGNU coreutils 8.32                          January 2026                                     COMM(1)",
            "subsections": []
        }
    },
    "summary": "comm - compare two sorted files line by line",
    "flags": [
        {
            "flag": "-1",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-2",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-3",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--check-order",
            "arg": null,
            "description": "check that the input is correctly sorted, even if all input lines are pairable"
        },
        {
            "flag": "",
            "long": "--nocheck-order",
            "arg": null,
            "description": "do not check that the input is correctly sorted --output-delimiter=STR separate columns with STR"
        },
        {
            "flag": "",
            "long": "--total",
            "arg": null,
            "description": "output a summary"
        },
        {
            "flag": "-z",
            "long": "--zero-terminated",
            "arg": null,
            "description": "line delimiter is NUL, not newline --help display this help and exit"
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit Note, comparisons honor the rules specified by 'LCCOLLATE'."
        }
    ],
    "examples": [
        "comm -12 file1 file2",
        "Print only lines present in both file1 and file2.",
        "comm -3 file1 file2",
        "Print lines in file1 not in file2, and vice versa."
    ],
    "see_also": [
        {
            "name": "join",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/join/1/json"
        },
        {
            "name": "uniq",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/uniq/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Select or reject lines common to two files. Both files must be sorted.",
        "examples": [
            {
                "description": "Produce three tab-separated columns: lines only in first file, lines only in second file, and common lines",
                "command": "comm {{file1}} {{file2}}"
            },
            {
                "description": "Print only lines common to both files",
                "command": "comm -12 {{file1}} {{file2}}"
            },
            {
                "description": "Print only lines common to both files, reading one file from `stdin`",
                "command": "cat {{file1}} | comm -12 - {{file2}}"
            },
            {
                "description": "Get lines only found in first file, saving the result to a third file",
                "command": "comm -23 {{file1}} {{file2}} > {{file1_only}}"
            },
            {
                "description": "Print lines only found in second file, when the files aren't sorted",
                "command": "comm -13 <(sort {{file1}}) <(sort {{file2}})"
            }
        ]
    }
}