Writing toolsRemove duplicate lines

Remove duplicate lines

Keep the first copy of each line and remove exact repeats. The remaining lines stay in their original order.

Add or drop TXT, Markdown, CSV, TSV, LOG, DOCX, ODT, or PDF files.

What Remove Duplicate Lines is for

If you combine two shopping lists, some items may appear twice. You can keep the first copy of each item without sorting the list or losing the order you use in the store.

How to use Remove Duplicate Lines

Paste one item per line and choose Remove duplicates. If your list reads Tea, Oats, Tea, the result is Tea followed by Oats. A space at the end of a line can change that result.

Tea
Oats
Tea
Tea 

Paste all four lines above, including the space after the last Tea. Only the third line disappears. The last Tea stays because of its trailing space. A lowercase tea would also stay on its own line.

How should I clean a list from several sources?

A space after “Tea” probably doesn’t matter on a shopping list. Trim the whitespace first, then remove duplicates. You’ll be left with Tea and Oats. Keep leading spaces if they mark levels in a list of instructions.

Repeated blank lines are duplicates too, even when they appear in different places. If blank lines separate your lists by supplier, process each supplier’s list separately to keep those groups intact.