# Count, Sort, Remove Duplicates: wc, sort and uniq

wc counts lines, words and characters, sort puts lines in order, as text or with -n as numbers, and uniq merges repeated lines that sit next to each other, so sort | uniq -c | sort -rn ranks how often each line appears.

![Cheat sheet for the lesson Count, Sort, Remove Duplicates: wc, sort and uniq: wc counts lines, words and characters, sort puts lines in order, as text or with -n as numbers, and uniq merges repeated lines that sit next to each other, so sort | uniq -c | sort -rn ranks how often each line appears.](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/892eb384ae7a49478c44790df05c3f32.webp)

- Category: Bash
- Level: Apprentice
- Tags: linux, sort-and-uniq, unix, wc
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/bash-count-sort-unique-cheat-sheet
