Report or filter out repeated lines in a file (POSIX)
uniq [-c] [-d|-u] [-f fields] [-s chars]
[input_file [output_file]]
Deprecated syntax:
uniq [-c] [-d|-u] [-n] [+m]
[input_file [output_file]]
Neutrino
- -n
- (deprecated, replaced by -f) Ignore the first
n fields when doing comparisons, where
n is a number.
- +m
- (deprecated, replaced by -s) Ignore the first
m characters when doing comparisons, where
m is a number.
- -c
- Precede each output line with the number of times the line
occurred in the input.
- -d
- 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.
- -u
- Suppress the writing of lines that are repeated in the input.
- input_file
- The pathname of the input file. If you don't specify any input files, the
standard input is used.
- output_file
- 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
is used.
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:
uniq datfile
- LC_TYPE
- 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
- Success
- > 0
- An error occurred.
If output_file is created, it isn't removed when an
error occurs.
sort