uniq(1)
Name
uniq − report repeated lines in a file
Syntax
uniq [−udc[+n][−n]] [input[output]]
Description
The uniq command 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. For further information, see sort(.).
Options
The n arguments specify skipping an initial portion of each line in the comparison:
−nSkips specified number of fields. A field is defined as a string of non-space, non-tab characters separated by tabs and spaces from its neighbors.
+nSkips specified number of characters in addition to fields. Fields are skipped before characters.
−cDisplays number of repetitions, if any, for each line.
−dDisplays only lines that were repeated.
−uDisplays only unique (nonrepeated) lines.
If the −u flag is used, just the lines that are not repeated in the original file are output. The −d option specifies that one copy of just the repeated lines is to be written. The normal mode output is the union of the −u and −d mode outputs.
The −c option supersedes −u and −d and generates an output report in default style but with each line preceded by a count of the number of times it occurred.