Skip to content
Documents·1 min read·

Remove duplicate lines

Keep the first copy of each line and drop later repeats, with optional trimming and case folding.

The answer

The first time a line appears, it stays. Later copies are removed. You can trim surrounding spaces and treat upper and lower case as the same line.

Result

Lines kept

a

Duplicate lines removed

2

What do you want to do next?

How this works

Lines are separated by line breaks. The tool remembers each line it has already kept and skips a later line with the same key. Order of the first copies does not change.

Trimming removes spaces at the ends before the comparison, and the kept line is the trimmed one. Ignoring case compares a lowercase copy but keeps the original casing of the first line.

Practical steps

  1. 1

    Paste one item per line.

  2. 2

    Leave trimming on unless the spaces themselves are part of the line.

  3. 3

    Turn case sensitivity on only when “A” and “a” are different entries.

Examples

  • “a”, then “a”, then “A”

    With case ignored, only the first “a” remains, and two lines are removed.

Common mistakes

  • ×

    Ignoring case when the list is a set of codes that differ only by case.

Frequently asked questions

Which copy is kept?

The first one. Later duplicates are counted and dropped.

Does a blank line count?

Yes. Repeated blank lines collapse to the first blank line.

Continue reading