uniq(1)uniq(1)NAMEuniq - report repeated lines in a file
fields] chars] [input_file [output_file]]
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 speci‐
fied, but output_file is not, results are printed to standard output.
input_file and output_file must not be the same file.
recognizes the following options when comparing adjacent lines:
Print those lines that are repeated in the original file.
Print copy only of each repeated line in the input file.
Generate an output report in default style
except that each line is preceded by a count of the num‐
ber of times it occurred. If this option is specified,
the and options are ignored if either or both are also
If none of the options or are present, prints the results of the union
of the and 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
Two options are provided for skipping an initial portion of each line
when making comparisons:
Ignore the first
fields fields, together with any blanks before
each. fields is a positive decimal integer. A
field is defined as a string of non-space, non-
tab characters separated by tabs and/or spaces
from its neighbors.
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 charac‐
must be equal to the value it had when the input files were sorted.
determines the interpretation of text within files as single- and/or
multi-byte characters, and defines a space character when the or option
determines the language in which messages are displayed.
If or is not specified in the environment or is set to the empty
string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default
of "C" (see lang(5)) is used instead of If any internationalization
variable contains an invalid setting, behaves as if all international‐
ization variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
Exit values are:
0 Successful completion.
>0 Error condition occurred.
was developed by OSF and HP.
SEE ALSOcomm(1), sort(1).