GNU bug report logs -
#30242
help
Previous Next
Full log
Message #7 received at control <at> debbugs.gnu.org (full text, mbox):
[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)]
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.