Linux "uniq" Command Line Options and Examples
report or omit repeated lines

Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output). With no options, matching lines are merged to the first occurrence. Mandatory arguments to long options are mandatory for short options too.


Usage:

uniq [OPTION]... [INPUT [OUTPUT]]






Command Line Options:

-c
prefix lines by the number of occurrences
uniq -c ...
-d
only print duplicate lines, one for each group
uniq -d ...
-D
print all duplicate lines
uniq -D ...
--all-repeated[
like -D, but allow separating groups with an empty line; METHOD={none(default),prepend,separate}
uniq --all-repeated[ ...
-f
avoid comparing the first N fields
uniq -f ...
--group[
show all items, separating groups with an empty line; METHOD={separate(default),prepend,append,both}
uniq --group[ ...
-i
ignore differences in case when comparing
uniq -i ...
-s
avoid comparing the first N characters
uniq -s ...
-u
only print unique lines
uniq -u ...
-z
line delimiter is NUL, not newline
uniq -z ...
-w
compare no more than N characters in lines
uniq -w ...
--help
display this help and exit
uniq --help ...
--version
output version information and exitA field is a run of blanks (usually spaces and/or TABs), then non-blank characters. Fields are skipped beforechars.Note: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first,or use 'sort -u' without 'uniq'. Also, comparisons honor the rules specified by 'LC_COLLATE'.AUTHORWritten by Richard M. Stallman and David MacKenzie.REPORTING BUGSGNU coreutils online help: <http://www.gnu.org/software/coreutils/>Report uniq translation bugs to <http://translationproject.org/team/>COPYRIGHTCopyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later<http://gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent per‐mitted by law.
uniq --version ...