Plain text data

SAMPLE_DATA='abc
def
def
xyz
def
abc
def'

e.g.

$ echo "$SAMPLE_DATA" | uniq

Unique

$ uniq

Add count.

$ uniq -c

Add count and sort by highest count first:

$ uniq -c | sort -r

Show name first and then count:

$ uniq -c | awk '{print $2, $1}'

Sort

$ sort

Unique values.

$ sort -u

Reverse th eorder.

$ sort -r