www.LinuxHowtos.org
UNIQ
Section: User Commands (1)Updated: February 2026
Index Return to Main Contents
NAME
uniq - report or omit repeated linesSYNOPSIS
uniq [,OPTION/]... [,INPUT /[,OUTPUT/]]DESCRIPTION
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.
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-c'-c, --countX'tty: link'
- prefix lines by the number of occurrences
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-d'-d, --repeatedX'tty: link'
- only print duplicate lines, one for each group
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-D'-DX'tty: link'
- print all duplicate lines
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-al-repeated'--all-repeated[=METHOD]X'tty: link'
- like -D, but allow separating groups with an empty line; METHOD={none(default),prepend,separate}
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-f'-f, --skip-fields=,NX'tty: link'/
- avoid comparing the first N fields
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-group'--group[=METHOD]X'tty: link'
- show all items, separating groups with an empty line; METHOD={separate(default),prepend,append,both}
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-i'-i, --ignore-caseX'tty: link'
- ignore differences in case when comparing
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-s'-s, --skip-chars=,NX'tty: link'/
- avoid comparing the first N characters
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-u'-u, --uniqueX'tty: link'
- only print unique lines
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-z'-z, --zero-terminatedX'tty: link'
- line delimiter is NUL, not newline
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#uni-w'-w, --check-chars=,NX'tty: link'/
- compare no more than N characters in lines
- X'tty: link https://www.gnu.org/software/coreutils/uniq#uni-help'--helpX'tty: link'
- display this help and exit
- X'tty: link https://www.gnu.org/software/coreutils/uniq#uni-version'--versionX'tty: link'
- output version information and exit
A field is a run of blanks (usually spaces and/or TABs), then non-blank characters. Fields are skipped before chars.
'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'.
AUTHOR
Written by Richard M. Stallman and David MacKenzie.REPORTING BUGS
Report bugs to: bug-coreutils@gnu.org
Report Gentoo bugs to: https://bugs.gentoo.org/
GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
Report any translation bugs to <https://translationproject.org/team/>
SEE ALSO
comm(1), join(1), sort(1)
Full documentation <https://www.gnu.org/software/coreutils/uniq>
or available locally via: info aq(coreutils) uniq invocationaq
Packaged by Gentoo (9.10 (p0))
Copyright © 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.