How to compare two lists and find the added and removed entries

By TechCompare · Updated · How we check

Put one entry per line and sort both lists the same way. Lines with a minus sign are only in the first list, and lines with a plus sign are only in the second.

The example

3 changes: 2 lines removed, 2 added

Original: subscribers.txtChanged: subscribers.txt
1ana@example.com1ana@example.com
2Removedben@example.com
3chloe@example.com2chloe@example.com
4Removeddev@example.com3AddedDev@example.com
5emma@example.com4emma@example.com
5Addedfarid@example.com

Two exports of the same list rarely match. A mailing list gains and loses people, a product feed drops a SKU, a server list picks up a new host. Put one entry per line, paste each version on its own side, and the diff shows every entry that's only in one of the lists.

Changes in the example
3
2 lines removed, 2 added
Lines
5 and 5
Original and changed text
Category
Files and data
Text diff guides

How this is calculated

The example compares two versions of a short subscriber list. As typed, the tool finds 3 changes: ben left, farid joined, and dev's address now starts with a capital letter. With Ignore case on, the result is 2 changes: 1 line removed, 1 added. The domain part of an email address ignores case, and most mail providers ignore it before the @ too, so the capital letter isn't a real change for this list.

Order matters in a line diff. The tool looks for the longest run of lines the two lists share in the same order, so a shuffled list shows changes even when it holds the same entries. Sort both lists before you compare them. On macOS or Linux, sort old.txt > old-sorted.txt does it, and spreadsheet apps can sort a column before you copy it.

Duplicates count too. If one list has the same entry twice, the extra copy shows as an added line. sort -u sorts and drops duplicates in one step.

For long lists on the command line, comm -3 old-sorted.txt new-sorted.txt prints only the entries that aren't in both files. It needs sorted input, the same way this tool needs sorted lists to give a clean result.

Verdict

Sort both lists, remove duplicates and then compare. The diff then reads like two short reports: minus lines are entries that left, plus lines are entries that joined. Turn on Ignore case for email addresses and hostnames, where capital letters don't change who or what an entry points to.

More Text Diff scenarios

Frequently asked questions

How do I find entries that are in one list but not the other?
Paste each list into one box with one entry per line, sorted the same way. Lines marked with a minus sign are only in the first list, and lines with a plus sign are only in the second.
Why does the diff show changes for entries that are in both lists?
A text diff compares lines in order. If the same entries appear in a different order, some of them show as removed in one place and added in another. Sort both lists first and those false changes go away.
Does it ignore spaces at the end of a line?
Not by default. Turn on Ignore whitespace and spaces or tabs anywhere in a line stop counting, including the trailing ones that often sneak in when you copy from a spreadsheet.