GNU bug report logs - #30242
help

Previous Next

Package: grep;

Reported by: Masoudi <hassan_masoudi2000 <at> yahoo.com>

Date: Wed, 24 Jan 2018 21:01:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

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 30242 in the body.
You can then email your comments to 30242 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#30242; Package grep. (Wed, 24 Jan 2018 21:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Masoudi <hassan_masoudi2000 <at> yahoo.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Wed, 24 Jan 2018 21:01:02 GMT) Full text and rfc822 format available.

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

From: Masoudi <hassan_masoudi2000 <at> yahoo.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: help
Date: Wed, 24 Jan 2018 20:51:49 +0000 (UTC)
[Message part 1 (text/plain, inline)]
Hii want to copy some data from a file by using of grep...grep -n A HISTORY > outbut the desired information is not the line of A, and i need information located at the next line ( below line of A)
A  1   2   3
23   34  55
i mean i need the line 23 34 55.would you mind to help me please?many thanks
[Message part 2 (text/html, inline)]

Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Wed, 24 Jan 2018 22:23:02 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Wed, 24 Jan 2018 22:23:03 GMT) Full text and rfc822 format available.

Notification sent to Masoudi <hassan_masoudi2000 <at> yahoo.com>:
bug acknowledged by developer. (Wed, 24 Jan 2018 22:23:03 GMT) Full text and rfc822 format available.

Message #12 received at 30242-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Masoudi <hassan_masoudi2000 <at> yahoo.com>, 30242-done <at> debbugs.gnu.org,
 GNU bug control <control <at> debbugs.gnu.org>
Subject: Re: bug#30242: help
Date: Wed, 24 Jan 2018 16:22:32 -0600
[Message part 1 (text/plain, inline)]
tag 30242 notabug
thanks

On 01/24/2018 02:51 PM, Masoudi wrote:
> Hii want to copy some data from a file by using of grep...grep -n A HISTORY > outbut the desired information is not the line of A, and i need information located at the next line ( below line of A)
> A  1   2   3
> 23   34  55
> i mean i need the line 23 34 55.would you mind to help me please?many thanks

(Your email engine botched the formatting of your mail as rendered in
plain text; technical lists tend to frown on html mail as unnecessary
overhead and lousy rendering)

grep already supports this: use 'grep -A1 "$pattern"' to output a line
that matches and the line immediately following the match.  If you
further want ONLY the line after, you can do things like:

grep -n -A1 "$patt" | sed -n 's/^[1-9][0-9]*-//p'

which uses the decorate-act-undecorate paradigm (grep -n decorates
matches with 'line:' and followups with 'line-'; the sed then picks the
followups and removes the decorations).

As -A is already documented as a grep option, I'm closing this as not a
bug in the database.  However, feel free to followup with further
questions on the topic.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

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

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 22 Feb 2018 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 202 days ago.

Previous Next


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