.TH uniq "" "" Command
.PC "Remove/count repeated lines in a sorted file"
\fBuniq [\-cdu] [\-\fIn\^\fB] [+\fIn\^\fB] [\fIinfile\^\fB[\fIoutfile\^\fB]]\fR
.PP
.HS
.SH Options:
.IC "\fB\-c\fR"
Print duplication count with lines
.IC "\fB\-d\fR"
Print only duplicated lines
.IC "\fB\-n\fR"
Skip \fIn\fR fields during comparison
.IC "\fB+n\fR"
Skip \fIn\fR characters (after skipping fields)
.IC "\fB\-u\fR"
Print only non-repeated lines
.HE
.B uniq
reads input line by line from
.I infile
and writes all non-duplicated lines to
.IR outfile .
The input file must be sorted.
.B uniq
uses the standard input or output if either
.I infile
or
.I outfile
is omitted.
The following describes the available options:
.RS
.IP \fB\-c\fR
Print each line once, discarding duplicate lines; before
each line, print the number of times it appears within the file.
.IP \fB\-d\fR
Print only lines that are duplicated within the file;
print each line only once;
do not print any counts.
.IP \fB\-u\fR
Print only lines that are \fInot\fR duplicated within the file.
.RE
.PP
.B uniq
by default behaves as if both \fB\-u\fR and \fB\-d\fR were specified,
so it prints each unique line once.
.PP
Optional specifiers allow
.B uniq
to skip leading portions
of the input lines when comparing for uniqueness.
.RS
.IP \fB\-\fIn\fR
Skip
.I n
fields of each input line,
where a field is any number of non-white space
characters surrounded by any number of
white space characters (blank or tab).
.IP \fB+\fIn\fR
Skip
.I n
characters in each input line,
after skipping fields as above.
.RE
.SH "See Also"
.Xr "comm," comm
.Xr "commands," commands
.Xr "sort" sort
