tldr/pages/common/comm.md
Agniva De Sarker 3da76e4150 Applying the snake_case convention throughout the repo (#967)
* Applying the snake_case convention throughout the repo

- Also removing the file extension where not needed
- Adding {{ }} on a few old pages

* Addressing concerns

- Added {{ }} where they were missed out
- Removed spaces inside {{ }}
- Reverting "file" to "filename" to make it clearer

* Fixing the comments on nc page
2016-07-22 22:24:06 +02:00

24 lines
647 B
Markdown

# 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:
`comm {{file1}} {{file2}}`
- Print only lines common to both files:
`comm -12 {{file1}} {{file2}}`
- Print only lines common to both files, reading one file from stdin:
`cat {{file1}} | comm -12 - {{file2}}`
- Get lines only found in first file, saving the result to a third file:
`comm -23 {{file1}} {{file2}} > {{file1_only}}`
- Print lines only found in second file, when the files aren't sorted:
`comm -13 <(sort {{file1}}) <(sort {{file2}})`