# sort and uniq

say it: **“sort and yoo-NEEK”** **/sɔːrt ænd juˈnik/**

\`sort\` orders lines; \`uniq\` removes or counts repeats.

## What does `sort and uniq` do?

`sort` puts lines in order; `uniq` removes repeated neighboring lines (so sort first). `uniq -c` counts them.

```bash
sort names.txt | uniq -c | sort -rn | head
```

Level: Journeyman · [More Unix terms at this level](https://www.ask-codey.com/glossary?category=unix&level=3)

Updated: November 17, 2026

Source: https://www.ask-codey.com/glossary/sort-and-uniq
