User Commands uniq(1) NAME uniq - report or filter out repeated lines in a file SYNOPSIS /usr/bin/uniq /usr/bin/uniq [ options ] [infile [outfile]] ksh93 uniq [ options ] [infile [outfile]] DESCRIPTION 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. OPTIONS The following options are supported: -c, --count Output the number of times each line occurred along with the line. -d, --repeated|duplicates Output the first of each duplicate line. -D, --all-repeated[=delimit] Output all duplicate lines as a group with an empty line delimiter specified by delimit: none Do not delimit duplicate groups. prepend Prepend an empty line before each group. separate Separate each group with an empty line. e option value may be omitted. The default value is none. -f, --skip-fields=fields fields is the number of fields to skip over before checking for uniqueness. A field is the minimal string matching the BRE [[:blank:]]*[^[:blank:]]*. -i, --ignore-case Ignore case in comparisons. -s, --skip-chars=chars 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 the chars specifies more characters than are on the line, an empty string will be used for comparison. -u, --unique Output unique lines. -w, --check-chars=chars chars is the number of characters to compare after skipping any specified fields and characters. -n Equivalent to -f fields with fields set to n. +m Equivalent to -s chars with chars set to m. --man, --html, --nroff Prints builtin manual page in either plain text, HTML or nroff format. --help Prints basic help information --version Prints version information OPERANDS The following operands are supported: input_file A path name of the input file. If input_file is not specified, or if the input_file is -, the standard input will be used. output_file A path name of the output file. If output_file is not specified, the standard output will be used. The results are unspecified if the file named by output_file is the file named by input_file. EXAMPLES 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. SunOS 5.10 Last change: 20 Dec 1996 2 User Commands uniq(1) 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% ENVIRONMENT VARIABLES 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. EXIT STATUS The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES See attributes(5) for descriptions of the following attri- butes: SunOS 5.10 Last change: 20 Dec 1996 3 User Commands uniq(1) ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________| | CSI | Enabled | |_____________________________|_____________________________| | Interface Stability | Standard | |_____________________________|_____________________________| SEE ALSO comm(1), pack(1), pcat(1), ksh93(1), sort(1), uncompress(1), attributes(5), environ(5), standards(5) SunOS 5.10 Last change: 20 Dec 1996 4