Other way to approach this is to delete lines between MD5 & Network
activity, excluding those lines.

This should do that trick.

perl -e '$_=`cat ipfile`;s/(^MD5.+?$).+?(^Network\s*Activity.*?$)/\1
\2/msi;print'

now you can do a grep.

Cheers,
Uday.

On Thu, Jul 26, 2012 at 6:24 PM, Balasubramaniam Natarajan <
bala150...@gmail.com> wrote:

> Hi
>
> I have many text file like so
>
> *Input*
> $cat 1/reports/report.txt
>
> MD5 askldfansd23423mnavl;noja
>
> sdlkfasdf
> as;ldkjfasd
> ;laskdflasdf
> alsdfj;alsdf
> asdlkas;lgasdg
>
> Network Activity
>
> DNS:
>
> HTTP:
>
> Other Activity
>
>
> Now I need the output like shown below.
> *Output*
> MD5 askldfansd23423mnavl;noja
> Network Activity
> DNS:
> HTTP:
>
> I can get the first line by the command
> $*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 ?
>
>  <http://www.ae.iitm.ac.in/mailman/listinfo/ilugc>
>



-- 
Cheers
Uday.
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to