GNU bug report logs -
#26726
Support grepping multi-lines fixed-strings
Previous Next
To reply to this bug, email your comments to 26726 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#26726
; Package
grep
.
(Mon, 01 May 2017 06:54:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"ziyunfei" <446240525 <at> qq.com>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Mon, 01 May 2017 06:54:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I have the same need as http://stackoverflow.com/questions/14631794/check-if-file-contains-some-text-not-regex-in-unix#comment20438757_14631832.
$ cat file
foo
bar
$ echo "$fixed_string"
bar
foo
$ grep -Fzq "$fixed_string" file && echo "Matched" || echo "Not matched"
Matched # false positive, -z doesn't apply to -F
$ [[ "$(cat file)" = *"$fixed_string"* ]] && echo "Matched" || echo "not matched"
not matched # my workaround
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-grep <at> gnu.org
:
bug#26726
; Package
grep
.
(Mon, 01 May 2017 12:49:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 26726 <at> debbugs.gnu.org (full text, mbox):
On Mon, May 1, 2017 at 3:38 PM, ziyunfei <446240525 <at> qq.com> wrote:
> I have the same need as http://stackoverflow.com/questions/14631794/check-if-file-contains-some-text-not-regex-in-unix#comment20438757_14631832.
>
> $ cat file
> foo
> bar
>
> $ echo "$fixed_string"
> bar
> foo
>
> $ grep -Fzq "$fixed_string" file && echo "Matched" || echo "Not matched"
> Matched # false positive, -z doesn't apply to -F
>
>
> $ [[ "$(cat file)" = *"$fixed_string"* ]] && echo "Matched" || echo "not matched"
> not matched # my workaround
Consider using perl, i.e., this matches:
$ pat='foo
bar'
$ printf '%s\n' foo bar | perl -0 -ne 'm!\Q'"$pat"'\E! or die'
This does not match:
$ printf '%s\n' bar foo | perl -0 -ne 'm!\Q'"$pat"'\E! or die'
Died at -e line 1, <> chunk 1.
Severity set to 'wishlist' from 'normal'
Request was from
Paul Eggert <eggert <at> cs.ucla.edu>
to
control <at> debbugs.gnu.org
.
(Wed, 21 Jun 2017 21:31:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 362 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.