bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71252: why does grep match literal newlines when there are none, eve


From: Martin Schulte
Subject: bug#71252: why does grep match literal newlines when there are none, even with -z?
Date: Wed, 29 May 2024 08:08:57 +0200

Hi!

> I always thought, that grep is line based in a way that the current
> string doesn't hold the line terminator.
> If so, why does, e.g.:
>   $ printf 'foo' | grep $'\n'
>   foo
> match?

I was surprised at the first moment, too, but I think the answer is in first 
paragraph of the man page:

PATTERNS is one or more patterns separated by newline characters, and grep 
prints each line that matches a pattern.

Thus, grep $'a\nb' find all lines that either contain an a or a b.

Best regards

Martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]