Extract

Hi all

I want to extract text between

the patterns

<p class="h">
.....
.....
.....
<p class="t">SYNONYMS</p>

And also how to delete the text between the above two patterns.

I am having 700 files.

How to use the sed command for this.

Santhosh
sant527 [ Fr, 26 Oktober 2007 12:59 ] [ ID #1854887 ]

Re: Extract

sant527 [at] gmail.com wrote:
> Hi all
>
> I want to extract text between
>
> the patterns
>
> <p class="h">
> ....
> ....
> ....
> <p class="t">SYNONYMS</p>
>
> And also how to delete the text between the above two patterns.
>
> I am having 700 files.
>
> How to use the sed command for this.
>
> Santhosh
>

To print the selected lines:

awk '
/<p class=\"t\">SYNONYMS<\/p>/ { found = 0 }
found
/<p class=\"h\">/ { found = 1 }
' file

To print everything except the selected lines:

awk '
/<p class=\"t\">SYNONYMS<\/p>/ { found = 0 }
!found
/<p class=\"h\">/ { found = 1 }
' file

Regards,

Ed.
Ed Morton [ Fr, 26 Oktober 2007 16:13 ] [ ID #1854896 ]

Re: Extract

How to execute this code on files. Where should I give the file name.


On Oct 26, 7:13 pm, Ed Morton <mor... [at] lsupcaemnt.com> wrote:
> sant... [at] gmail.com wrote:
> > Hi all
>
> > I want to extract text between
>
> > the patterns
>
> > <p class="h">
> > ....
> > ....
> > ....
> > <p class="t">SYNONYMS</p>
>
> > And also how to delete the text between the above two patterns.
>
> > I am having 700 files.
>
> > How to use the sed command for this.
>
> > Santhosh
How to use these commands. I am new to awk

Should I write then i a file and then run the file. I have done that
but it shows nothing.

Can you guide how to use them on my files.



>
> To print the selected lines:
>
> awk '
> /<p class=\"t\">SYNONYMS<\/p>/ { found = 0 }
> found
> /<p class=\"h\">/ { found = 1 }
> ' file
>
> To print everything except the selected lines:
>
> awk '
> /<p class=\"t\">SYNONYMS<\/p>/ { found = 0 }
> !found
> /<p class=\"h\">/ { found = 1 }
> ' file
>
> Regards,
>
> Ed.
sant527 [ Di, 30 Oktober 2007 07:23 ] [ ID #1857399 ]
Linux » comp.unix.shell » Extract

Vorheriges Thema: Is there a log file to view linux load history
Nächstes Thema: how can I combine 'find' and 'cp' command ?