in reply to Re: Filtering certain multi-line patterns from a file
in thread Filtering certain multi-line patterns from a file
Thanks for helping satisfy my curiosity! Your alternate solutions are amazingly concise. Storing the buffered lines in an array is an interesting idea, and now I'm curious to try the same in Awk.
The "$1 >= timestamp" was my attempt at dealing with a timestamp line occurring immediately after another timestamp line, with no recognizable history entry between them. This could occur if the user manually typed in a line that matches the timestamp regex. It's a corner-case, and I sort of fudged it, saying, "as long as the second timestamp isn't less than the first, I'll assume it is a real timestamp and forget about the previous one.
So I was relying on string comparison even though the intent was mathematical comparison, since I knew both strings had the same # prefix followed by all digits.
I tested both of your alternate solutions out, and the only difference from my Awk script was how the @buf solution handled the above-mentioned corner-case (adjacent timestamp lines). It simply removed both adjacent timestamps, which is fine in my opinion.
Again, thanks for the intro by example!
|
|---|