uniq.1 (2010 09)
u
uniq(1) uniq(1)
NAME
uniq - report repeated lines in a file
SYNOPSIS
uniq [-udc [-f fields ][
-s chars ][input_file [ output_file ]]
DESCRIPTION
uniq reads the input text file input_file , comparing adjacent lines, and copies the result to output_file.If
input_file is not specified, the standard input and standard output are used. If input_file is specified, but
output_file is not, results are printed to standard output. input_file and output_file must not be the same
file.
Line-Comparison Options
uniq recognizes the following options when comparing adjacent lines:
-u Print only those lines that are not repeated in the original file.
-d Print one copy only of each repeated line in the input file.
-c Generate an output report in default style except that each line is preceded by a count of
the number of times it occurred. If this option is specified, the
-u and -d options are
ignored if either or both are also present.
If none of the options
u, d,or c are present, uniq prints the results of the union of the
-u and -d
options, producing a copy of the original input file with the second and succeeding copies of any repeated
lines removed. (Note that repeated lines must be adjacent in order to be found — see sort (1)).
Field-Skip Options
Two options are provided for skipping an initial portion of each line when making comparisons:
-f fields Ignore the first fields fields, together with any blanks before each. fields is a posi-
tive decimal integer. A field is defined as a string of non-space, non-tab characters
separated by tabs and/or spaces from its neighbors.
-s chars Ignore the first chars characters. chars is a positive decimal integer. Each line in
the input is assumed to be terminated with a new line character for purposes of
comparison. 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 interpretation of text within files as single- and/or multi-byte characters, and
defines a space character when the -f or -s option is used.
LC_MESSAGES determines the language in which messages are displayed.
If
LC_COLLATE, LC_CTYPE or LC_MESSAGES 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 occurred.
AUTHOR
uniq was developed by OSF and HP.
SEE ALSO
comm(1), sort(1).
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1