As an example the file with following content:
My dog
My dog is running
My dog is running fast
A cat
A cat is black
A cat is black and small
As a result I want to have only this two lines:
My dog is running fast
A cat is black and small
I would prefer to do it in one line command.
Tried many SED, AWK and UNIQ options but could not find a good solution.
I guess SED should be able to do it if it can read lines by two and print first line only if second line does not match it. But, cannot figure out how to do it.
>Solution :
The following seems to work:
sed -n ':a;$!N;s/^\([^\n]*\)\n\1/\1/;$!ta;P;D'