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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Severity: wishlist; Reported by: Matt Zand <mahdiumd@HIDDEN>; dated Thu, 3 Oct 2019 16:09:01 UTC; Maintainer for grep is bug-grep@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 37607 <at> debbugs.gnu.org:


Received: (at 37607) by debbugs.gnu.org; 2 Jan 2020 10:00:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 02 05:00:50 2020
Received: from localhost ([127.0.0.1]:38251 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1imxHd-0004Fz-PG
	for submit <at> debbugs.gnu.org; Thu, 02 Jan 2020 05:00:50 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49996)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1imxHc-0004Fn-Co
 for 37607 <at> debbugs.gnu.org; Thu, 02 Jan 2020 05:00:48 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id F00DF160054;
 Thu,  2 Jan 2020 02:00:42 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id IC_rEdsnPb5A; Thu,  2 Jan 2020 02:00:42 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3875B160058;
 Thu,  2 Jan 2020 02:00:42 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id WYLawMKSowq4; Thu,  2 Jan 2020 02:00:42 -0800 (PST)
Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com
 [23.242.74.103])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1096B160054;
 Thu,  2 Jan 2020 02:00:42 -0800 (PST)
Subject: Re: bug#37607: How to use Grep with Using -o
To: Matt Zand <mahdiumd@HIDDEN>, 37607 <at> debbugs.gnu.org
References: <CAJHWHyXX0R4rOKQ2XwNQ8xw+cH99_OKF=1ZUNq_MjUQVFWwZZQ@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <75f979cb-992d-5bfc-8803-10d5507541ab@HIDDEN>
Date: Thu, 2 Jan 2020 02:00:41 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.2.2
MIME-Version: 1.0
In-Reply-To: <CAJHWHyXX0R4rOKQ2XwNQ8xw+cH99_OKF=1ZUNq_MjUQVFWwZZQ@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37607
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

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.




Information forwarded to bug-grep@HIDDEN:
bug#37607; Package grep. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Oct 2019 16:08:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 03 12:08:54 2019
Received: from localhost ([127.0.0.1]:40882 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iG3ev-0006Dz-RR
	for submit <at> debbugs.gnu.org; Thu, 03 Oct 2019 12:08:54 -0400
Received: from lists.gnu.org ([209.51.188.17]:54127)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mahdiumd@HIDDEN>) id 1iG3R9-0005nC-Mu
 for submit <at> debbugs.gnu.org; Thu, 03 Oct 2019 11:54:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:49117)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mahdiumd@HIDDEN>) id 1iG3R8-0001cY-BU
 for bug-grep@HIDDEN; Thu, 03 Oct 2019 11:54:39 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 HTML_MESSAGE autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <mahdiumd@HIDDEN>) id 1iG3R7-000321-7N
 for bug-grep@HIDDEN; Thu, 03 Oct 2019 11:54:38 -0400
Received: from mail-vk1-xa42.google.com ([2607:f8b0:4864:20::a42]:43049)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <mahdiumd@HIDDEN>) id 1iG3R7-00031t-3E
 for bug-grep@HIDDEN; Thu, 03 Oct 2019 11:54:37 -0400
Received: by mail-vk1-xa42.google.com with SMTP id p189so737903vkf.10
 for <bug-grep@HIDDEN>; Thu, 03 Oct 2019 08:54:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=CopDsnQDOV0+AXzAMsvkCkWltOy0tZASiV0dgXZhiIM=;
 b=fs1CueSu927fQtD6PmaZSZD4Pu9f/jc26X5986eMYpDFTSirzEfqkgQXEmq7UD798q
 zK2hs6D6pRQ4xUXQSCh9V2dR2N7EK7nj7YswwXaA7yJ5QBe+HgsaH2FbbstpdFZnGlTW
 ehd6Yq5BwiT4PB4MTkHpNks4AiDmE/qUY6opRs44Vz4eobWF5Cs9dV6ECxBOMG0tHPlp
 c0QNXJuO30s1+0+k23GWT0Q9YobWsnhi6nfTu3w0ha7SO//OaZhOUC8/s8ocruRvS+K6
 2HvN6b6EYWvH58OG9wTt2tWx5JYLMGfOMGc5TWISa0uQNdBXS52aOaN/tXMOSV7yYEc3
 eeYw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=CopDsnQDOV0+AXzAMsvkCkWltOy0tZASiV0dgXZhiIM=;
 b=ufiihz3YkPf/YfUUAVjYHjd3J/mAMpxN/9a4jZLPsry1C1qYFs3FjaiJMUTyS3qOoU
 tDEyBwei6OPCQVMH8wo1/92bsRH/No4e3ubJY5FJX16KicyD8/+UHiEVqjY6PSgCl78O
 zIID0osEAD/XinB9Efc25Ug3SBjJ6S6hEe4D0CCundxXySg//xsjg1tZI//nH04Z1EOe
 Z6UuLE6bac6x3mPjn5sWu42/PKw4DFlpHMtnkFzF9WKdG7wYVVuNPQXvM7xlEdwvw81P
 SSYEBwwPqnC1lYKSG4wnSQcfLVJ0zGOoIt7QzpD1kv1/0sr0z8QW0LqeAIg/pimmU3wZ
 uQvA==
X-Gm-Message-State: APjAAAXRfhO+kt6YH1UhmRUK8zhmHZdzx8oLpYAsJX/3dy2geiWIUxDO
 Nm1CnvIr9BqBL/YttyanAHA+Xp3/miKVGWABgeRrMHcYwNs=
X-Google-Smtp-Source: APXvYqxHX/wHIWx6TSFx88J2IzUYYN17P3krSczPWS3T1zTO47m1K1k5Xb28AXdDsX06mYPqA4fWaWOx0z3+vXDhbrU=
X-Received: by 2002:a1f:2343:: with SMTP id j64mr5277093vkj.84.1570118076244; 
 Thu, 03 Oct 2019 08:54:36 -0700 (PDT)
MIME-Version: 1.0
From: Matt Zand <mahdiumd@HIDDEN>
Date: Thu, 3 Oct 2019 11:54:24 -0400
Message-ID: <CAJHWHyXX0R4rOKQ2XwNQ8xw+cH99_OKF=1ZUNq_MjUQVFWwZZQ@HIDDEN>
Subject: How to use Grep with Using -o
To: bug-grep@HIDDEN
Content-Type: multipart/alternative; boundary="00000000000030a9650594039a38"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::a42
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 03 Oct 2019 12:08:52 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--00000000000030a9650594039a38
Content-Type: text/plain; charset="UTF-8"

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/>

--00000000000030a9650594039a38
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">

<pre class=3D"gmail-message" style=3D"font-family:monospace;padding-top:0px=
;margin-top:0px;border-top:0px none;white-space:pre-wrap;color:rgb(0,0,0);f=
ont-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;fon=
t-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tr=
ansform:none;word-spacing:0px;background-color:rgb(254,254,254);text-decora=
tion-style:initial;text-decoration-color:initial"><span style=3D"font-famil=
y:arial,sans-serif">Hi,

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

printf &quot;banana\napple&quot; | grep --invert-match --only-matching &#39=
;ban&#39;

to produce

ana
apple

or

apple

, but it doesn&#39;t produce anything.

I need -o because I grep multiline pattern with -z.</span>
</pre><br class=3D"gmail-Apple-interchange-newline">

<br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"gmail_signature" dat=
a-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div=
><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div>Che=
ers,<br><br>Matt Zand<br></div><div>Cell: 202-420-9192<br>Work: 240-200-613=
1</div><div><a href=3D"https://myhsts.org/" target=3D"_blank">High School T=
echnology Services</a></div><div><a href=3D"https://dcwebmakers.com/" targe=
t=3D"_blank">DC Web Makers</a></div><div><a href=3D"https://coding-bootcamp=
s.com/" target=3D"_blank">Coding Bootcamps</a><br></div><div></div><br></di=
v></div></div></div></div></div></div></div></div></div></div></div>

--00000000000030a9650594039a38--




Acknowledgement sent to Matt Zand <mahdiumd@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#37607; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 2 Jan 2020 10:15:02 UTC

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