According to the documentation, option -z or --null-data should cause grep to treat newlines as ordinary data. Therefore, in the following example the regexp ^[1-4]$ should _not_ match the input data: $ printf '12\n34\0' | LC_ALL=en_US.utf8 grep -z -e '^[1-4]*$' | od -t x1 0000000 31 32 0a 33 34 00 0000006 Spelling it out as [1234] makes it work as expected: $ printf '12\n34\0' | LC_ALL=en_US.utf8 grep -z -e '^[1234]*$' | od -t x1 0000000 It is also locale dependent, I see the problem with LC_ALL=en_US.utf8 and LC_ALL=en_US, but not with LC_ALL=C.
Created attachment 425428 [details] emerge --info sys-apps/grep
sys-apps/grep-2.24 fixes the problem for me. Can this bug be closed?
sgtm!