maux
Star on GitHub Buy me a coffee

Manual / uniq

uniq(1)

UNIQ(1) General Commands Manual UNIQ(1)

uniq - report repeated lines

uniq [-cdu] [-f fields] [-s chars] [input [output]]

Uniq reads the input file comparing adjacent lines. In the normal case, the second and succeeding copies of repeated lines are removed; the remainder is written on the output file. Note that repeated lines must be adjacent in order to be found; see sort(1). Input and output default to standard input and standard output.

Print just the lines that are not repeated.
Print one copy of just the repeated lines.
Precede each selected line by its repeat count.
Ignore this many initial fields in comparisons. A field is a string of non-space, non-tab characters with preceding blanks.
Ignore this many further characters. Fields are skipped before characters.

The full original line is printed regardless of comparison skips. The -d and -u options are mutually exclusive.

/usr/man/UNIQ this page

sort(1), comm(1), licenses(1)

Exit status is 0 on success, 1 for file I/O failures, 2 for usage errors.

Lines longer than 255 bytes are treated as several logical lines. An existing longer output file is not shortened; choose a new output file. Do not use the input as the output.

September 19, 2026 maux