GNU bug report logs - #37607
How to use Grep with Using -o

Previous Next

Package: grep;

Reported by: Matt Zand <mahdiumd <at> gmail.com>

Date: Thu, 3 Oct 2019 16:09:01 UTC

Severity: wishlist

To reply to this bug, email your comments to 37607 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#37607; Package grep. (Thu, 03 Oct 2019 16:09:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Zand <mahdiumd <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Thu, 03 Oct 2019 16:09:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matt Zand <mahdiumd <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: How to use Grep with Using -o
Date: Thu, 3 Oct 2019 11:54:24 -0400
[Message part 1 (text/plain, inline)]
Hi,

Is it possible to output symbols which constitute non-matched parts of
text? For instance, I expect

printf "banana\napple" | grep --invert-match --only-matching 'ban'

to produce

ana
apple

or

apple

, but it doesn't produce anything.

I need -o because I grep multiline pattern with -z.




-- 
Cheers,

Matt Zand
Cell: 202-420-9192
Work: 240-200-6131
High School Technology Services <https://myhsts.org/>
DC Web Makers <https://dcwebmakers.com/>
Coding Bootcamps <https://coding-bootcamps.com/>
[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#37607; Package grep. (Thu, 02 Jan 2020 10:01:01 GMT) Full text and rfc822 format available.

Message #8 received at 37607 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Matt Zand <mahdiumd <at> gmail.com>, 37607 <at> debbugs.gnu.org
Subject: Re: bug#37607: How to use Grep with Using -o
Date: Thu, 2 Jan 2020 02:00:41 -0800
On 10/3/19 8:54 AM, Matt Zand wrote:

> Is it possible to output symbols which constitute non-matched parts of
> text? For instance, I expect
> 
> printf "banana\napple" | grep --invert-match --only-matching 'ban'
> 
> to produce
> 
> ana
> apple
> 
> or
> 
> apple
> 
> , but it doesn't produce anything.

Unfortunately the -v and -o options don't currently combine in that way. Perhaps
they should, or perhaps another option could be added to do what you want. I'll
mark this as a wishlist item.




Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Thu, 02 Jan 2020 10:01:01 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.