Does not support patterns containing escaped newline character, except with -P
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grep (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
$ printf 'a
b\0b' | grep --null-data "a
b" | hexdump -C
00000000 61 0a 62 00 62 00 |a.b.b.|
00000006
expect
00000000 61 0a 62
EDIT:
Apparently, in the above the pattern string is considered as two patterns 'a' and 'b'.
With -P you get
$ printf 'a\nb\0b' | grep -zP 'a
b' | hexdump -C
grep: the -P option only supports a single pattern
However, if the newline is coded as '\n' in the pattern, it works, but only with -P
$ printf 'a\nb\0b' | grep -zP 'a\nb' | hexdump -C
00000000 61 0a 62 00 |a.b.|
00000004
$ printf 'a\nb\0b' | grep -z 'a\nb' | hexdump -C
$ printf 'a\nb\0b' | grep -zE 'a\nb' | hexdump -C
$ printf 'a\nb\0b' | grep -zF 'a\nb' | hexdump -C
I expect it should work by other matcher selectors than -P, too.
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: grep 2.25-1~16.04.1
ProcVersionSign
Uname: Linux 4.4.0-45-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: XFCE
Date: Fri Nov 11 12:58:27 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2015-11-21 (355 days ago)
InstallationMedia: Xubuntu 15.10 "Wily Werewolf" - Release amd64 (20151021)
SourcePackage: grep
UpgradeStatus: Upgraded to xenial on 2016-06-24 (139 days ago)
description: | updated |
description: | updated |
summary: |
- Does not support patterns containing newline + Does not support patterns containing escaped newline character, except + with -P |
In awk \n in regex means newline.