uniqdisplay unique lines of sorted file |
Command |
uniq
[-c
|-d
|-u
]
[-f
number1]
[-s
number2]
[input_file
[output_file]]
uniq
[-c
|-d
|-u
]
[-
number]
[+
number]
[input_file
[output_file]]
uniq
manipulates lines which occur more than once in a file.
The file must be sorted, since uniq
only compares adjacent
lines. When you invoke this command with no options, it writes only one copy of
each line in input_file to output_file. If you do not specify
input_file or you specify -
, uniq
reads
the standard input. If you do not specify output_file,
uniq
uses the standard output.
-c
precedes each output line with the number of times that line occurred in the input.
-d
displays only lines which are repeated (one copy of each line).
-f
number1ignores the first number1 fields when comparing lines. Blanks separate fields in the input.
-s
number2ignores the first number2 characters when comparing lines. If
you specify both -s
and -f
,
uniq
ignores the first number2 characters after
the first number1 fields.
-u
displays only those lines which are not repeated.
-c
, -d
,
or -u
options.
-
numberis an obsolete equivalent to -f
number.
+
numberis an obsolete equivalent to -s
number.
is a filter which prints one copy of each different line in its sorted input.uniq
compares lines starting with the 2nd character of the 3rd field.uniq -f 2 -s 1
outputs one instance of each repeated line in the input (and omits all unique lines).uniq -d
0
Successful completion.
1
Failure due to any of the following:
-f
-s
You specified -s
but did not supply a number after
the -s
.
You specified -f
but did not supply a number after
the -f
.
In a -
number or
+
number construct, number wasn't valid.
This could arise from a typo when entering a -
option.