comm compares two sorted lists in one pass
Which ids are in file A and not in B is a question comm answers directly, three columns: only in A, only in B, in both.
comm -23 <(sort a.txt) <(sort b.txt) # only in a
comm -12 <(sort a.txt) <(sort b.txt) # in bothBoth inputs must be sorted. The process substitution sorts them inline.
shell