Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

comm(1)

sort(1)

environ(5)

uniq(1)

NAME

uniq − report repeated lines in a file

SYNOPSIS

uniq [ [ −u ] [ −d ] [ −c ] [ +n ] [ −n ] ] [ input [ output ] ]

AVAILABILITY

SUNWesu

DESCRIPTION

uniq reads the input file comparing adjacent lines.  In the normal case, the second and succeeding copies of repeated lines are removed; the remainder is written on the output file.  Input and output should always be different.  Note that repeated lines must be adjacent in order to be found; see sort(1). 

OPTIONS

If the −d and the −u options are used, the last option used on the command line will supersede the other option. 

−u If the −u flag is used, just the lines that are not repeated in the original file are output. 

−d The −d option specifies that one copy of just the repeated lines is to be written.  The normal mode output is the union of the −u and −d mode outputs. 

−c The −c option supersedes −u and −d and generates an output report in default style but with each line preceded by a count of the number of times it occurred. 

The n arguments specify skipping an initial portion of each line in the comparison:

−n The first n fields together with any blanks before each are ignored.  A field is defined as a string of non-space, non-tab characters separated by tabs and spaces from its neighbors. 

+n The first n characters are ignored.  Fields are skipped before characters. 

EXAMPLES

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%

ENVIRONMENT

If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of uniq for each corresponding locale category is determined by the value of the LANG environment variable.  If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables.  If none of the above variables is set in the environment, the "C"  (U.S. style) locale determines how uniq behaves. 

LC_CTYPE
Determines how uniq handles characters. When LC_CTYPE is set to a valid value, uniq can display and handle text and filenames containing valid characters for that locale.  uniq can display and handle Extended Unix code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide.  uniq can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid. 

LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses.  In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).

SEE ALSO

comm(1), sort(1), environ(5)

SunOS 5.4  —  Last change: 14 Sep 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026