uniq

The command that collapses runs of identical adjacent lines into one; -c prefixes each with how many there were.

In more detail

It only compares neighbouring lines, so sort the input first. sort | uniq -c | sort -nr is the classic way to count how often each value appears.

Related terms

Taught in

References

Certification courses