1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-28 22:04:55 +02:00
tldr/pages/common/comm.md
Lucas Gabriel Schneider a5fe31bc47
multiple pages: format technical tokens (#5119)
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
2021-01-31 12:05:18 -05:00

647 B

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}})