0

I've got no problem just blanket removing duplicates - sort -u input.txt > output.txt does that easily. But I want to only remove sequential, subsequent duplicates and I'm not sure how to do that. Here's an example:

Input:

One
Two
Two
Three
Four
Five
Five
Six
Seven
Seven
Seven
Three
Three
Two
One

Output:

One
Two
Three
Four
Five
Six
Seven
Three
Two
One

Has anyone worked out a simple bash sequence to do this, or know of a *NIX command line utility that does?

Edit: clarified the example.

Christopher Penn
  • 539
  • 4
  • 14

0 Answers0