Exploring uniq - Linux Commands

| 2 min read

What is the uniq Command in Linux?

The uniq command in Linux is a useful utility that filters out or reports repeated lines in a file or standard input. It’s typically used to identify or remove duplicate lines, making it easier to manage and analyze data that might contain redundant entries.

Basic syntax:

uniq [option] [input-file] [output-file]

Example:

uniq file-name

Options

OptionDescription
-cPrecede each output line with the number of occurrences
-dOnly print duplicate lines, one for each group
-uOnly print unique lines
-iIgnore differences in case when comparing
-w NCompare no more than N characters in a line

Additional Help

You can explore more by using the commands:

uniq --help
# or
man uniq

Resources

7 Linux Uniq Command Examples to Remove Duplicate Lines from File

Thank you!

Thank you for your time and for reading this!