bash - --line-regexp option with null data -
consider command:
printf 'alpha\nbravo\ncharlie\n' | grep --line-regexp --quiet bravo
grep sees 3 lines separated newline, , matches bravo line. consider command:
printf 'alpha\0bravo\0charlie\0' | grep --line-regexp --quiet bravo
my thinking tells me because have not used --null-data
, grep should see 1 or 0 lines separated newline, , fail match bravo
followed newline. not, succeeds first command, why this?
this behavior was introduced grep 2.21:
when searching binary data, grep may treat non-text bytes line terminators. can boost performance significantly.
so happens binary data, non-text bytes (including newlines) treated line terminators. if want change behavior, can:
use
--text
. ensure newlines line terminatorsuse
--null-data
. ensure null bytes line terminators
Comments
Post a Comment