Template:Short description Template:About Template:Lowercase title {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text.

OverviewEdit

The command 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). For example, the following command lists the unique lines in a file, sorted by the number of times each occurs:

<syntaxhighlight lang="sh"> $ sort file | uniq -c | sort -n </syntaxhighlight>

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

HistoryEdit

First appearing in Version 3 Unix,<ref name="reader">Template:Cite tech report</ref> uniq is now available for a number of different Unix and Unix-like operating systems. It is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification.<ref>Template:Man</ref>

The version bundled in GNU coreutils was written by Richard Stallman and David MacKenzie.<ref>Template:Man</ref>

A uniq command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.<ref>MSX-DOS2 Tools User's Manual by ASCII Corporation</ref>

The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project<ref>CoreUtils for Windows</ref> and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.<ref>Native Win32 ports of some GNU utilities</ref>

The Template:Mono command has also been ported to the IBM i operating system.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

See alsoEdit

ReferencesEdit

Template:Reflist

External linksEdit

Template:Sister project

Template:Unix commands Template:Plan 9 commands Template:Core Utilities commands