COMM(1)

πŸ’– COMM(1) πŸ’–

okay bestie, gather round, because we're about to talk about comm, the general commands manual's most underrated little icon ✨


🌸 NAME 🌸

comm β€” compare two sorted files line by line, fr fr.

When FILE1 or FILE2 (but like, not both, bestie) is -, read standard input. 🫢

With no options at all, you get three-column output, and here's the tea: column one has the lines that are unique to FILE1, column two has the lines unique to FILE2, and column three is the lines that are common to both files. main character behavior honestly πŸ‘‘


✨ SYNOPSIS ✨

comm [OPTION]... FILE1 FILE2

πŸ¦‹ DESCRIPTION πŸ¦‹

So the whole vibe is: compare two sorted files line by line. That's it. That's the job. πŸ’…

When FILE1 or FILE2 (again, not both, pick a lane) is -, read standard input.

With no options, produce three-column output:

  • column one = lines unique to FILE1
  • column two = lines unique to FILE2
  • column three = lines that are common to both files

πŸŽ€ OPTIONS πŸŽ€

  • -1 β€” suppress column 1, aka the lines unique to FILE1. bye bestie πŸ‘‹
  • -2 β€” suppress column 2, aka the lines unique to FILE2. also gone πŸ’€
  • -3 β€” suppress column 3, aka the lines that appear in both files. not them being erased 😭
  • --output-delimiter <STR> β€” separate the columns with STR. you pick the little separator, it's giving customizable 🎨
  • -z, --zero-terminated β€” line delimiter is NUL, not newline. yes literally the NUL character, we're being fancy ✨
  • --total β€” output a summary. little recap moment, we love a summary 🧾
  • --check-order β€” check that the input is correctly sorted, even if all input lines are pairable. nosy but in a helpful way πŸ™ˆ
  • --nocheck-order β€” do not check that the input is correctly sorted. minding my own business energy 🌈
  • -h, --help β€” print help πŸ†˜
  • -V, --version β€” print version ⭐
  • <FILE1> β€” the first file, the file one, the original πŸ’œ
  • <FILE2> β€” the second file, the sequel, the encore 🌸

πŸ‘‘ VERSION πŸ‘‘

v(uutils coreutils) 0.12.0


πŸ”₯ EXAMPLES πŸ”₯

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)
bestie, real talk: these examples are provided by the tldr-pages project at https://tldr.sh under the CC BY 4.0 License. And please note that, because uutils is a work in progress, some examples might fail. no cap, it's a WIP 🚧

πŸ’œ SIGN-OFF πŸ’œ

this page is from v(uutils coreutils) 0.12.0, dated 2026-09-25, and it lives in the General Commands Manual, section 1, COMM(1). slay, go sort your files, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from