From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

uniq is a Unix utility which, when fed a text file, outputs the file with adjacent identical lines collapsed to one.

First appearing in Version 3 Unix,[1] it is a kind of filter program. Typically it is used after sort. It can also output only the duplicate lines (with the -d option), or add the number of occurrences of each line (with the -c option).

An example: To see the list of lines in a file, sorted by the number of times each occurs:

sort file | uniq -c | sort -n

Using uniq like this is common when building pipelines in shell scripts.

See also


  1. ^ McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139.

External links

  • uniq's Linux manpage
  • SourceForge UnxUtils – Port of several GNU utilities to Windows
Retrieved from "https://en.wikipedia.org/w/index.php?title=Uniq&oldid=838510127"
This content was retrieved from Wikipedia : http://en.wikipedia.org/wiki/Uniq
This page is based on the copyrighted Wikipedia article "uniq"; it is used under the Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA). You may redistribute it, verbatim or modified, providing that you comply with the terms of the CC-BY-SA