uniq
Remove consecutive duplicate lines
uniq removes adjacent duplicate lines. It only works on sorted input. Always pipe sort before uniq. uniq -c prefixes each line with a count.
Example
$ echo -e 'apple\napple\nbanana' | sort | uniq -c | sort -rn
2 apple
1 banana
Tip: Type it yourself in the terminal below - reading is not the same as doing.