Skip to content

How to stop rg after num matches? #2695

Answered by BurntSushi
Podbrushkin asked this question in Q&A
Discussion options

You must be logged in to vote

I have a huge file without EOL chars

That's your problem. ripgrep (and grep) are line oriented search tools. Fundamentally, they operate as-if iterating over every line in a file and printing each matching line. This is not just an implementation detail, it is the conceptual model on which the program works. If you don't have line oriented data, the grep programs are usually less useful. There are "hacks" to make grep tools work on binary data by changing the line terminator (e.g., the --null-data flag makes ripgrep use the NUL byte as a line terminator instead of \n), but generally speaking, if you can't formulate your data as lines then grep is not the right tool.

This should make it …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants