Skip to main content
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

The Insider's Guide to Accessing NLM Data

sort-uniq-count-rank


As new Insider's Guide classes are no longer being offered, this site is not currently being updated. Please refer to NCBI's E-utilities documentation for more up-to-date information.


The sort-uniq-count-rank command combines a series of Unix commands (including sort and uniq) to sort a series of lines of text alphabetically, grouping together the duplicate lines. The function then counts how many occurrences there are of each unique line, removes all duplicate lines, and then sorts the list of unique lines by how frequently they occur, from most frequent to least frequent. The numerical frequency count is also displayed.

Input

One or more lines of text.

Output

One or more unique lines of text, accompanied by frequency counts, sorted from most frequent to least frequent.

Arguments

The sort-uniq-count-rank command does not accept arguments.

Example

Given a series of rows of text (for example, a list of author names):

Noy S
Iverson GL
Del Bigio MR
Sawyer Q
Vesci B
Zukerman SL
Iverson GL
Wallace PW
Stern RA
Noy S
Baugh CM
[...]

The sort-uniq-count-rank command will output:

12      Iverson GL
12      Zuckerman SL
11      Guskiewicz KM
11      Kerr ZY
11      Solomon GS
10      Covassin T
10      Stern RA
9       Arnett PA
9       Baugh CM
9       Kroshus E
9       Mihalik JP
[...]

Last Reviewed: July 30, 2021