Closed acelticsfan closed 10 months ago
That's a neat idea. I will keep this in mind and put it on a TODO list. However, I can't guarantee it's included in an update, because there will be some (performance) caveats to implement a tail version of max count.
Note that -K NUM
skips NUM lines before searching, so that's like tail -n NUM FILE | ugrep PATTERN
, but ugrep -K NUM PATTERN FILE
outputs the correct line numbers of FILE
.
Thanks. Regarding performance, that makes sense since you would still have to read the whole file. ugrep is fast enough that for me it wouldn't really matter.
I thought hard and long about this and considered some initial designs.
But the addition of a tail
-like match count to count matches from the end is not really feasible to implement without negatively impacting the overall design and speed of ugrep.
I would think that a simpler use by piping the ugrep output to tail
works reasonably well, to get the last matching lines that ugrep outputs as matches. Then use ugrep --color=always
to force color output to tail
.
I understand. Thanks for the pointers.
The --max-count feature is nice. It's basically like ugrep 'PATTERN' - | head .
I'm proposing a complementary feature that is equivalent to ugrep 'PATTERN' - |tail.
Perhaps it could be called --max-count-tail, whereby one only gets the last N matching lines of a stream or file.
In a log file, some times the only data I'm interested in is the most recent data at the bottom of the file.