[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30242: help

From: Eric Blake
Subject: bug#30242: help
Date: Wed, 24 Jan 2018 16:22:32 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

tag 30242 notabug

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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]