GNU bug report logs - #20605
Grep command

Previous Next

Package: grep;

Reported by: "Lakshmana Rao Adabala, Shanmukha" <Shanmukha.LakshmanaRaoAdabala <at> emc.com>

Date: Mon, 18 May 2015 17:45:03 UTC

Severity: normal

Tags: notabug

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20605 in the body.
You can then email your comments to 20605 AT debbugs.gnu.org in the normal way.

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#20605; Package grep. (Mon, 18 May 2015 17:45:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Lakshmana Rao Adabala, Shanmukha" <Shanmukha.LakshmanaRaoAdabala <at> emc.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Mon, 18 May 2015 17:45:04 GMT) Full text and rfc822 format available.

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

From: "Lakshmana Rao Adabala, Shanmukha"
 <Shanmukha.LakshmanaRaoAdabala <at> emc.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: Grep command 
Date: Mon, 18 May 2015 17:28:18 +0000
[Message part 1 (text/plain, inline)]
Hi Team,

I would like to know how to get the grep output in the same order.

For example:

I am using the following order :  04A2,17F5,04A4

[cid:image001.png <at> 01D091AF.B34719B0]

I am expecting output in the following order.

04A2
17F5
04A4

But I am getting the output in the below order

04A2
04A4
17F5

Please let me if any additional switches to use.

-Shan

Thanks and regards,
Lakshmanrao ASVV, RHEL, EMCIE Symmetrix, VPLEX, RecoverPoint,
Implementation Delivery Specialist,
EMC Global Services - GPS,
Direct dial: 91-080-40029564 Ext:7859561
Mobile: +91 9886326677
US Toll Free: 1-800782-4362 Ext:7859561
EMC² Where Information Lives.







[Message part 2 (text/html, inline)]
[image001.png (image/png, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#20605; Package grep. (Tue, 19 May 2015 00:15:03 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "Lakshmana Rao Adabala, Shanmukha" <Shanmukha.LakshmanaRaoAdabala <at> emc.com>,
 20605 <at> debbugs.gnu.org
Subject: Re: bug#20605: Grep command
Date: Mon, 18 May 2015 17:14:25 -0700
Lakshmana Rao Adabala, Shanmukha wrote:
> I would like to know how to get the grep output in the same order.

Grep's output is the same order as its input.  That appears to be what it's 
doing for you.  There's no option to change this.




Information forwarded to bug-grep <at> gnu.org:
bug#20605; Package grep. (Tue, 19 May 2015 02:18:02 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: "Lakshmana Rao Adabala, Shanmukha" <Shanmukha.LakshmanaRaoAdabala <at> emc.com>,
 20605 <at> debbugs.gnu.org
Subject: Re: bug#20605: Grep command
Date: Mon, 18 May 2015 20:17:13 -0600
[Message part 1 (text/plain, inline)]
On 05/18/2015 11:28 AM, Lakshmana Rao Adabala, Shanmukha wrote:
> Hi Team,
> 
> I would like to know how to get the grep output in the same order.
> 
> For example:
> 
> I am using the following order :  04A2,17F5,04A4
> 
> [cid:image001.png <at> 01D091AF.B34719B0]

Screenshots are hard to parse; it's better to paste actual screen text
content.

It looks like you are using Windows, due to the unusual quoting
paradigms used on the command line:

service <at> VPLEXCLU2:~> cat 852* | grep -E ""04A4"|"17F5"|"04A2""

On a Unix system, the quoting would be:
cat 852* | grep -E "04A4|17F5|04A2"

> 
> I am expecting output in the following order.
> 
> 04A2
> 17F5
> 04A4

It sounds like you were hoping that grep would make three passes over
your input stream (the concatenated 852* files) - first outputting all
matches to the pattern 04A4, then all matches to the pattern 17F5, then
all matches to the pattern 04A2.  But that's not how grep works.  It
makes a single pass over your input, and for each line, it checks all
alternations within the pattern at once.

> 
> But I am getting the output in the below order
> 
> 04A2
> 04A4
> 17F5

Which means that the first line that matched is one that matched your
third alternative in the single pattern.

> 
> Please let me if any additional switches to use.

The only way to get output in a particular order is to do three separate
passes of grep, on one non-alternating pattern each, rather than one
pass with a three-alternation pattern.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Added tag(s) notabug. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sat, 30 May 2015 20:05:04 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 20605 <at> debbugs.gnu.org and "Lakshmana Rao Adabala, Shanmukha" <Shanmukha.LakshmanaRaoAdabala <at> emc.com> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sat, 30 May 2015 20:05:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 28 Jun 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 50 days ago.

Previous Next


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