tldr/pages/common/comm.md

24 lines
548 B
Markdown
Raw Normal View History

2015-12-28 13:04:58 +00:00
# comm
> Select or reject lines common to two files. Both files must be sorted.
- Produce three tab-separated columns: lines only in first file, lines only in second file and common lines:
2015-12-28 13:04:58 +00:00
`comm {{file1}} {{file2}}`
- Print only lines common to both files:
2015-12-28 13:04:58 +00:00
`comm -12 {{file1}} {{file2}}`
- Print only lines common to both files, read one file from stdin:
2015-12-28 13:04:58 +00:00
`cat {{file1}} | comm -12 - {{file2}}`
- Print lines only found in first file:
2015-12-28 13:04:58 +00:00
`comm -23 {{file1}} {{file2}}`
- Print lines only found in second file:
2015-12-28 13:04:58 +00:00
`comm -13 {{file1}} {{file2}}`