Report or filter out repeated lines in a file (POSIX)
uniq [-c] [-d|-u] [-f fields] [-s chars]
uniq [-c] [-d|-u] [-n] [+m]
- (deprecated, replaced by -f) Ignore the first
n fields when doing comparisons, where
n is a number.
- (deprecated, replaced by -s) Ignore the first
m characters when doing comparisons, where
m is a number.
- Precede each output line with the number of times the line
occurred in the input.
- Suppress the writing of lines that aren't repeated in the input.
- -f fields
- Ignore the first fields on each input line when
doing comparisons, where fields is a positive
decimal integer. A field is a string of nonblank
characters separated from adjacent fields by blanks.
- -s chars
- Ignore the first chars characters when doing
comparisons, where chars is a positive decimal
integer. If specified in conjunction with the -f option,
the first chars characters after the first
fields fields are ignored.
- Suppress the writing of lines that are repeated in the input.
- The pathname of the input file. If you don't specify any input files, the
standard input is used.
- The pathname of the output file. This name must differ from the name of
the input file. If you don't specify an output file, the standard output
The uniq utility reads an input text file, comparing adjacent
lines, and writes one copy of each input line to the output. The second and
succeeding copies of repeated adjacent input lines aren't written.
||To obtain a report of unique lines in a file, the input file must
be sorted prior to running uniq.|
Look for repeated adjacent lines in datfile:
- The locale for character classification, used to determine the characters
constituting a blank in the current locale.
||QNX Neutrino currently supports only the POSIX (i.e. C) locale.|
- > 0
- An error occurred.
If output_file is created, it isn't removed when an