Linux Commands Helper

💬 Your AI-powered Linux assistant

uniq Command - Report or Omit Repeated Lines

The uniq command is used to filter out or report repeated lines in a file or from standard input. It is commonly used to process sorted files to remove or count duplicate lines.

Syntax

uniq [options] [input_file [output_file]]

Examples

sort file.txt | uniq

Remove duplicate lines from file.txt (must be sorted first).

uniq -c file.txt

Prefix lines by the number of occurrences.

uniq -d file.txt

Only print duplicate lines.

Notes

  • Input must be sorted for uniq to detect duplicates correctly.
  • Commonly used with sort for deduplication tasks.
  • Can also output only unique or only duplicate lines with options.

Related Linux Commands:

© 2025 Linux Commands Helper. All rights reserved.

This project is under construction. Feedback and contributions are welcome.

Fazier badgeFeatured on Startup Fame