search result is less than grep because of stopped searching binary file after match #2570
-
hi, executing command "rg -i word", I found only part of matched lines are outputed, but with Is this a feature of |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
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 |
Beta Was this translation helpful? Give feedback.
-
The
|
Beta Was this translation helpful? Give feedback.
-
never mind, Just confirm if it's a expected behavior of |
Beta Was this translation helpful? Give feedback.
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…