Print only lines that appear more than once.

Section: sort and uniq

Show duplicate lines only

bash
bash
sort file.txt | uniq -d
Explanation

Great for spotting repeated entries or duplicates in lists.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing sort and uniq
Sort and deduplicate
Return sorted unique lines.
OpenIn sheetbashsame section
Count duplicate lines
Count occurrences of adjacent duplicate lines.
OpenIn sheetbashsame section
Sort lines alphabetically
Default lexicographic sort.
OpenIn sheetbashsame section
Sort in reverse order
Invert the output order.
OpenIn sheetbashsame section
Sort numerically
Order lines by numeric value.
OpenIn sheetbashsame section
Sort human-readable sizes
Sort values like 1K, 5M, 2G.
OpenIn sheetbashsame section