uniq - report or filter out repeated lines in a file
/usr/bin/uniq [-c | -d | -u] [-f fields] [-s char] [input_file [output_file]]
/usr/bin/uniq [-c | -d | -u] [-n] [+ m] [input_file [output_file]]
uniq [-cdiu] [-D[delimit]] [-f fields] [-s chars] [-w chars] [input_file [output_file]]
uniq [-cdiu] [-D[delimit]] [-n] [+m] [-w chars] [input_file [output_file]]
The uniq utility reads an input file comparing adjacent lines and writes one copy of each input line on the output. The second and succeeding copies of repeated adjacent input lines are not written.
Repeated lines in the input are not detected if they are not adjacent.
The uniq built-in in ksh93 is associated with the /bin or /usr/bin path. It is invoked when uniq is executed without a pathname prefix and the pathname search finds a /bin/uniq or /usr/bin/uniq executable.
uniq reads an input, comparing adjacent lines, and writing one copy of each input line on the output. The second and succeeding copies of the repeated adjacent lines are not written.
If output_file is not specified, uniq writes to standard output. If input_file is not specified, or if input_file is -, uniq reads from standard input, and the start of the file is defined as the current offset.
The following options are supported by /usr/bin/uniq:
-c
-d
-f fields
[[:blank:]]*[^[:blank:]]*
If fields specifies more fields than appear on an input line, a null string is used for comparison.
+m
-n
-s chars
-u
The following options are supported by the uniq built-in command is ksh93:
-c
--count
-d
--repeated | duplicates
-D
--all-repeated[=delimit]
Specify delimit as one of the following:
none
prepend
separate
The value for delimit can be omitted. The default value is none.
-f
--skip-fields=fields
-i
--ignore-case
+m
-n
-s
--skip-chars=chars
If specified with the -f option, the first chars after the first fields are ignored. If the chars specifies more characters than are on the line, an empty string is used for comparison.
-u
--uniq
-w
--check-chars=chars
The following operands are supported:
input_file
output_file
Example 1 Using the uniq Command
The following example lists the contents of the uniq.test file and outputs a copy of the repeated lines.
example% cat uniq.test This is a test. This is a test. TEST. Computer. TEST. TEST. Software. example% uniq -d uniq.test This is a test. TEST. example%
The next example outputs just those lines that are not repeated in the uniq.test file.
example% uniq -u uniq.test TEST. Computer. Software. example%
The last example outputs a report with each line preceded by a count of the number of times each line occurred in the file:
example% uniq -c uniq.test 2 This is a test. 1 TEST. 1 Computer. 2 TEST. 1 Software. example%
See environ(5) for descriptions of the following environment variables that affect the execution of uniq: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
0
>0
See attributes(5) for descriptions of the following attributes:
|
|
The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted.
comm(1), ksh93(1), , pcat(1), sort(1), uncompress(1), attributes(5), environ(5), standards(5)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |