Text · 52 tools · nothing uploads

Unique lines with counts

Unique lines with counts. Runs entirely on your device, nothing is uploaded.

Input

live

Unique lines with counts lists each distinct line of a pasted text once, in the order it first appeared, prefixed with how many times it occurred. Comparison is on the exact line text, so a line differing only in trailing whitespace counts as different. Counting happens before order is decided, so the first occurrence is always the one printed.

Questions

Which occurrence of a repeated line gets kept?

The first one. The tool walks the file top to bottom, and the position where a line first appears determines both where it lands in the output and which exact copy, whitespace included, gets printed.

How exact does a match have to be?

Exact. Comparison is on the whole line as a string, with no trimming and no case folding, so two lines differing only by a trailing space are counted as different lines with their own separate counts.

What does the count column count?

How many times that exact line occurred anywhere in the file, including the first occurrence itself, so a line appearing once shows a count of 1.

Are the counts and the order calculated together?

Counting happens as the whole file is read once, and the first-seen order is recorded at the same time, so the numbers reflect the complete file even though each line is printed only once, at its first position.

What happens to a trailing newline in the input?

It is preserved on the output, the same way it is across the other line-based tools in this group.

Compare

ToolRuns on the CLILive as you type
Unique lines with countsYesYes
Number linesYesYes
Reverse linesYesYes
Shuffle linesYesYes
Sort lines by lengthYesYes
Prefix or suffix linesYesYes
Extract linesYesYes

Related Text tools