Skip to content

search result is less than grep because of stopped searching binary file after match #2570

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

You must be logged in to vote

Generally speaking, ripgrep and GNU grep's binary file detection works the same way. They both look for a NUL byte, and if one is found, the search will stop once a match is found. Since you didn't say which grep you're using and since you didn't provide any reproduction, I can't provide a more specific analysis than that. But note it is a non goal for them to behave identically.

Otherwise this is intended behavior. The issue is that if ripgrep didn't treat binary data special, then stuff can be dumped to your terminal and royally mess things up. It's a trade off.

Indeed, if you want to forcefully treat everything as plain text, then -a/--text is the correct path there. The same is also t…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Comment options

You must be logged in to vote
5 replies
@BurntSushi
Comment options

@bigdogs
Comment options

@BurntSushi
Comment options

@bigdogs
Comment options

@BurntSushi
Comment options

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