uniq(1)
NAME
uniq − report repeated lines in a file
SYNOPSIS
uniq [−udc [+n] [−n]] [input [output]]
DESCRIPTION
uniq reads the input text 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. input and output should always be different. Note that repeated lines must be adjacent in order to be found (see sort(1)). If the −u flag is used, only those lines that are not repeated in the original file appear in the output. The −d option specifies that one copy of only 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 except that each line is preceded by a count of the number of times it occurred.
The ±n arguments specify skipping an initial portion of each line in the comparison:
−n The first n fields, together with any blanks before each, are ignored. A field is defined as a string of non-space, non-tab characters separated by tabs and spaces from its neighbors.
+n The first n characters are ignored. Fields are skipped before characters.
EXTERNAL INFLUENCES
Environment Variables
LC_COLLATE must be equal to the value it had when the input files were sorted.
LC_CTYPE determines the space character when the −n or +n is used.
LANG determines the language in which messages are displayed.
If LC_COLLATE or LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, uniq behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
Exit values are:
0 Successful completion.
>0 Error condition occured.
SEE ALSO
STANDARDS CONFORMANCE
uniq: SVID2, XPG2, XPG3, proposed POSIX.2 FIPS (June 1990)
Hewlett-Packard Company — HP-UX Release 8.05: June 1991