I saw this question, and I want to do something similar: Print line if value in column changes
Essentially, I'll have a (tab-delimited) file like this
A 0 10 loss
A 10 20 loss
A 20 30 loss
A 30 40 no
A 40 50 no
A 50 60 no
A 60 70 no
A 70 80 gain
...
and I want to print both lines where the column 4 changes from (e.g.) "loss" -> "no" or "no" -> "gain", so the output would be
A 20 30 loss
A 30 40 no
A 60 70 no
A 70 80 gain
The value in the column 4 could be anything, but I want to print both lines bracketing the change.
This looks like something I could do with awk, but I'm not too familiar with it.