Skip to content

Show only N matches at end of file #1888

Discussion options

You must be logged in to vote

There is no way, no.

To answer the next natural question: no, I don't think I will add it. In order to know if a match is part of the last N matches, you have to know where the last match is. In order to know where the last match is, you need to search the entire input. Thus, by necessity, implementing this feature requires buffering the last N matches in memory and only printing them once the search has completed. ripgrep isn't really set up to do that.

Instead, I suggest using tail: rg foo | tail -n 10 will print only the last ten matches.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jungle-boogie
Comment options

Answer selected by jungle-boogie
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants