Consider this command:
printf \'alpha\\nbravo\\ncharlie\\n\' | grep --line-regexp --quiet bravo
grep sees 3 lines separated by newline, and mat
This behavior was introduced with Grep 2.21:
When searching binary data, grep now may treat non-text bytes as line terminators. This can boost performance significantly.
So what happens now is that with binary data, all non-text bytes (including newlines) are treated as line terminators. If you want to change this behavior, you can:
use --text
. This will ensure that only newlines are line terminators
use --null-data
. This will ensure that only null bytes are line terminators