uniq -c file.txt

Category: Text Processing

uniq -c file.txt

Prefix each unique line with its occurrence count

Counts how many times each repeated line appears, printing the count next to each line.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.