Afficher un message
Vieux 31/05/2007, 08h14   #5
samuel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to catch a block which contains some keywords with sed

On May 25, 12:10 am, sil <dsphunx...@gmail.com> wrote:
> On May 23, 2:42 am, samuel <samuelz...@gmail.com> wrote:
>
>
>
>
>
> > Hi ,

>
> > Now I need to analyze a file which is composed of several blocks ,
> > which is defined as below :

>
> > Start
> > <content>
> > <content>
> > ......
> > <content>
> > End

>
> > And I need to catch/print all the blocks which contains several
> > specific keywords such "cpu" "dma" in the content part.

>
> > Does any know to do this in sed or in other ways ?

>
> > Thanks in advance !

>
> > Samuel

>
> Does sed '/cpu/!d; /dma/!d' filename not work for this...- Hide quoted text -
>
> - Show quoted text -


Thanks Ed and all,
perl -0777 -ne'print for grep /cpu|dma/, (/^Start\n(.*?)^End$/mgs)'
Or
perl -0777 -ne'print for grep /cpu|dma/, (/^Start\n.*?^End\n/mgs)'


did works in this case.

Rgds,

Samuel

  Réponse avec citation
 
Page generated in 2,02884 seconds with 9 queries