comm
Quick Reference
Command Name:
comm
Category:
file comparison
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
Syntax
comm [OPTION]... FILE1 FILE2
Options
Option | Description |
---|---|
-1 |
Suppress lines unique to FILE1 |
-2 |
Suppress lines unique to FILE2 |
-3 |
Suppress lines that appear in both files |
--check-order |
Check that the input is correctly sorted, even if all input lines are pairable |
--nocheck-order |
Do not check that the input is correctly sorted |
--output-delimiter=STR |
Separate columns with STR |
--total |
Output a summary |
-z, --zero-terminated |
Line delimiter is NUL, not newline |
--help |
Display help message and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the comm
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Show lines unique to file1, unique to file2, and common to both comm file1.txt file2.txt
Advanced Examples:
# Use with sort to ensure input is sorted sort file1.txt > sorted1.txt sort file2.txt > sorted2.txt comm sorted1.txt sorted2.txt