uniq -- Filtering Duplicates

The uniq utility can be used to filter adjacent duplicate lines in files or in the text provided through standard input.

See man uniq and IEEE Std 1003.1-2017-uniq for details.