[Ilugc] Grep two lines from text file with different A and B switch

  • From: bala150985@xxxxxxxxx (Balasubramaniam Natarajan)
  • Date: Thu, 26 Jul 2012 22:56:37 -0400

On Thu, Jul 26, 2012 at 12:14 PM, Shakthi Kannan <shakthimaan at 
gmail.com>wrote:

| I can get the first line by the command
<bala150985 at gmail.com> wrote:
| $*grep "MD5 " */reports/report.txt*
| If I want the next Network Activity
| $*grep "Network Activity" -A5 */reports/report.txt*
|
| However how can I get to do both of these in the same line so that their
| outputs are interleaved ?
\--

Learn to read manual pages.

  $ man grep

As stated, multiple search patterns can be given using the "-e" option.

I would also encourage you to use a standard file format (xml, yaml,
json, for example) for report.txt, so it can be parsed easily.


The problem with $grep "MD5 |Network Activity" -A5 */reports/report.txt* is
that after all the search I am getting 5 lines however I wanted to know if
we can make two different -A switches for a single Grep command.

-- 
Regards,
Balasubramaniam Natarajan
www.etutorshop.com/moodle/

Other related posts: