I want to delete the consecutive duplicate lines. i.e. for example
**test.txt**
car
speed is good
bike
slower than car
plane
super fast
super fast
bullet train
super fast
This removes all the duplicate lines except the 1st occurance.
perl -ne 'print unless $a{$_}++'
But i want the ouput to be
**test.txt**
car
speed is good
bike
slower than car
plane
super fast
bullet train
super fast
I tried this oneliner but this doesnt do anything but just prints the input.
perl -00 -F'<\w+>|</\w+>' -i.bak -lane 'foreach(@F){if ($_=~/\w+/ && ($a ne $_)){print "$_";$a=$_;}}'
How to do this???