|Skip Navigation Links|
|Exit Print View|
|man pages section 1: User Commands Oracle Solaris 11 Express 11/10|
- report or filter out repeated lines in a file
/usr/bin/uniq [options] [infile [outfile]]
uniq [options] [infile [outfile]]
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 the output file, outfile, is not specified, uniq writes to standard output. If no infile is given, or if the infile is -, uniq reads from standard input with the start of the file is defined as the current offset.
Output the number of times each line occurred along with the line.
Output the first of each duplicate line.
Output all duplicate lines as a group with an empty line delimiter specified by delimit:
Do not delimit duplicate groups.
Prepend an empty line before each group.
Separate each group with an empty line.
The option value can be omitted. The default value is none.
fields is the number of fields to skip over before checking for uniqueness. A field is the minimal string matching the BRE [[:blank:]]*[^[:blank:]]*.
Ignore case in comparisons.
chars is the number of characters to skip over before checking for uniqueness. If specified along with -f, the first chars after the first fields are ignored. If chars specifies more characters than are on the line, an empty string is used for comparison.
Output unique lines.
chars is the number of characters to compare after skipping any specified fields and characters.
Equivalent to -f fields with fields set to n.
Equivalent to -s chars with chars set to m.
Prints built-in manual page in either plain text, HTML or nroff format.
Prints basic help information.
Prints version information.
The following operands are supported:
A path name of the input file. If infile is not specified, or if the infile is -, the standard input is used.
A path name of the output file. If outfile is not specified, the standard output is used. The results are unspecified if the file named by outfile is the file named by infile.
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:
An error occurred.
See attributes(5) for descriptions of the following attributes: