Skip to content

.tip

· one of the small things

comm compares two sorted lists in one pass

"Which ids are in file A but not in B?" is a question comm answers directly. It prints three columns: only in A, only in B, and in both.

comm -23 <(sort a.txt) <(sort b.txt)   # only in a
comm -12 <(sort a.txt) <(sort b.txt)   # in both

Both inputs have to be sorted, and the process substitution sorts them inline.

shell