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.



Command Line Options:

prefix lines by the number of occurrences
uniq -c ...
only print duplicate lines, one for each group
uniq -d ...
print all duplicate lines
uniq -D ...
like -D, but allow separating groups with an empty line; METHOD={none(default),prepend,separate}
uniq --all-repeated[ ...
avoid comparing the first N fields
uniq -f ...
show all items, separating groups with an empty line; METHOD={separate(default),prepend,append,both}
uniq --group[ ...
ignore differences in case when comparing
uniq -i ...
avoid comparing the first N characters
uniq -s ...
only print unique lines
uniq -u ...
line delimiter is NUL, not newline
uniq -z ...
compare no more than N characters in lines
uniq -w ...
display this help and exit
uniq --help ...
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: <>Report uniq translation bugs to <>COPYRIGHTCopyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later<>.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 ...