Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities

uniq

Oregon Coast

uniq
Previous | Next

        Report Unique Lines in Text Files

Usage:  uniq [-hbcdiuw-] [-f fields] [-s chars]
                [-<n>] [+<m>] [ file1 file2 ...]

   uniq does a quick, simple string comparison of adjacent lines
   in text files, normally just discarding any duplicates as it
   copies its input to stdout.

   There are some diff-style options for ignoring upper-/lower-
   case differences or treating white spaces of any length as
   equal, etc.  Also, you can optionally choose to list only the
   lines that occur just once or only those that have duplicates.

   If several files are given, the effect is the same as if they
   were pasted together, one right after another into one long
   file.

Options:

   -b           Blank spaces of any length compare equal.  Ignore
                any leading or trailing white space on each line.
   -c           Preface each line with a count of the number of
                times it occurred.
   -d           Duplicates.  Only the lines which have at least
                one duplicate are reported.
   -i           Ignore character case.
   -u           Unique lines.  Only the lines which occur only
                once are reported.
   -w           White space is ignored totally.
   -f fields    Ignore the first <fields> fields on each input
                line when doing comparisons, where <fields> is
                is a positive decimal integer.  A field is
                defined as a maximal string of tabs or spaces
                followed by non-tab, non-space characters.
   -s chars     Ignore the first <chars> characters when doing
                comparisons.  If used in conjunction with the
                -f option, the first <chars> characters after
                the first <fields> fields will be ignored.
   -<n>         An older form of field specification, now
                considered obsolete by POSIX.  Equivalent to
                -f <n>.
   +<m>         An older form of character specification, now
                considered obsolete by POSIX.  Equivalent to
                -s <m>.
   -h           Help.  (This screen.)
   --           End of options.

Previous | Next