Linux command
comm 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Compare two sorted files
comm [file1] [file2]
Show lines unique to first file
comm -23 [file1] [file2]
Show lines unique to second file
comm -13 [file1] [file2]
Show lines common to both
comm -12 [file1] [file2]
Compare with custom delimiter
comm --output-delimiter='|' [file1] [file2]
Compare unsorted files
comm <(sort [file1]) <(sort [file2])
说明
comm compares two sorted files line by line. Produces three columns: lines unique to file1, lines unique to file2, and lines common to both. Part of GNU coreutils.
参数
- -1
- Suppress column 1 (lines unique to file1)
- -2
- Suppress column 2 (lines unique to file2)
- -3
- Suppress column 3 (common lines)
- --check-order
- Check input is properly sorted
- --nocheck-order
- Skip sort order verification
- --output-delimiter= _STR_
- Separate columns with STR
- --total
- Output summary counts
- -z, --zero-terminated
- Line delimiter is NUL
- --help
- Display help
- --version
- Show version
FAQ
What is the comm command used for?
comm compares two sorted files line by line. Produces three columns: lines unique to file1, lines unique to file2, and lines common to both. Part of GNU coreutils.
How do I run a basic comm example?
Run `comm [file1] [file2]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -1 do in comm?
Suppress column 1 (lines unique to file1)