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
Option | Description |
---|---|
-c | Precede each output line with the number of occurrences |
-d | Only print duplicate lines, one for each group |
-u | Only print unique lines |
-i | Ignore differences in case when comparing |
-w N | Compare 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!