normal:
echo "a b a b c c c" | tr ' ' '\n'
a
b
a
b
c
c
c
uniq : no two subsequent repeating lines
echo "a b a b c c c" | tr ' ' '\n' | uniq
a
b
a
b
c
sorted
echo "a b a b c c c" | tr ' ' '\n' | sort
a
a
b
b
c
c
c
sort -u : no two repeating lines
echo "a b a b c c c" | tr ' ' '\n' | sort -u
a
b
c
sort / uniq: all distinct
echo "a b a b c c c" | tr ' ' '\n' | sort | uniq
a
b
c
counts distinct occurrences
echo "a b a b c c c" | tr ' ' '\n' | sort | uniq -c
2 a
2 b
3 c
only lines which are not repeated (not sorted first)
echo "a b a b c c c" | tr ' ' '\n' | uniq -u
a
b
a
b
only lines which are not repeated (after sorting)
echo "a b a b c c c Z" | tr ' ' '\n' | sort | uniq -u
Z
uniq -d : only print duplicate lines, one for each group
echo "a b a b c c c" | tr ' ' '\n' | uniq -d
c
.. counted
echo "a b a b c c c" | tr ' ' '\n' | uniq -dc
3 c