--line-regexp option with null data

后端 未结 1 1007
萌比男神i
萌比男神i 2021-01-28 17:06

Consider this command:

printf \'alpha\\nbravo\\ncharlie\\n\' | grep --line-regexp --quiet bravo

grep sees 3 lines separated by newline, and mat

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-28 17:38

    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

    0 讨论(0)
提交回复
热议问题