-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for stop after num matches #159
Comments
I believe GNU grep has this, right? I'm inclined to add it, but could you provide a use case for it? One slight For single file search, its usefulness is a bit clearer I think. On Oct 9, 2016 4:42 AM, "Markus Engelbrecht" notifications@github.com
|
Yes GNU grep has this. The use case is repeatedly filtering stdin (or a single file) with a match limit to look for a specific match. If the match is not found the user can refine the pattern until it is. |
@mgee But even if you give a list of files, I'm not necessarily saying that this is a good reason to not have this flag, but I am saying that it seems like bad UX. |
@BurntSushi true, this option only has good UX when used with stdin or a single file (my use case). Maybe a note in the documentation about non-determinism when |
@BurntSushi I just realized that what I previously wrote could be misunderstood. With a list of files I meant I have a single file which contains a list of filenames which I successively filter with a pattern. In each step the pattern can be refined to reduce the list of matched filenames until the desired filename is found. |
@mgee Ah, I did misunderstand that. Thanks for clarifying. |
Thanks! |
GNU’s Grep
Instead, you have to Now Ripgrep provides a clearer description ( |
|
Not sure why this is closed as Completed, since RipGrep doesn't have option "to stop after num matches".
|
It was closed as completed because a
When reporting behavior that doesn't work like you expect, please include a reproduction. And please don't bump issues that are 7 years old. Please just take a moment to minimize it. Here, watch:
The above output should make it clear that the
That is, it is a limit on the number of matching lines and not the number of matches. To me, this suggests your
Of course they can. Watch:
Both ripgrep and grep will stop searching after printing the first match.
I can't make heads or tails of what you're saying here. The default behavior is to choose the buffering strategy based on where ripgrep is printing (line buffering for tty and block buffering for a file). By passing |
Add an option to stop reading a file after
num
matches have been found. This equals the-m
,--max-count
option from grep.The text was updated successfully, but these errors were encountered: