Sed matching lines ?

Sed matching lines ?

Post by gu.. » Thu, 04 May 2000 04:00:00



Hello all,

I'm trying to match this block of text at the end
of a file.

        </TABLE></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>

there may possibly be blank lines at the end of
the file after </HTML> and
</TABLE></TD></TR>
</TABLE>
occurs multiple times earlier in the file.

I need to replace this text with

        </TABLE>
Some new test here.
</TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Any help would be appreciated. This is part of a
large sed script but this last bit is just a
little bit tricky.

Thanks,
Doug

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Sed matching lines ?

Post by dougjam.. » Thu, 04 May 2000 04:00:00




> Hello all,

> I'm trying to match this block of text at the end
> of a file.

>         </TABLE></TD></TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>

> there may possibly be blank lines at the end of
> the file after </HTML> and
> </TABLE></TD></TR>
> </TABLE>
> occurs multiple times earlier in the file.

> I need to replace this text with

>         </TABLE>
> Some new test here.
> </TD></TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>

> Any help would be appreciated. This is part of a
> large sed script but this last bit is just a
> little bit tricky.

This seems to work.

\#</TABLE></TD></TR>#{
N
N
N
N
s#</TABLE></TD></TR>\n</TABLE>\n</FORM>\n</BODY>\n</HTML>#</TABLE>\
\
Some new text here\
\
</TD></TR>\
</TABLE>\
</FORM>\
</BODY>\
</HTML>#g

Quote:}

Is there a better way ?

Thanks,
Doug

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Sed matching lines ?

Post by gu.. » Thu, 04 May 2000 04:00:00




> Hello all,

> I'm trying to match this block of text at the end
> of a file.

>         </TABLE></TD></TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>

> there may possibly be blank lines at the end of
> the file after </HTML> and
> </TABLE></TD></TR>
> </TABLE>
> occurs multiple times earlier in the file.

> I need to replace this text with

>         </TABLE>
> Some new test here.
> </TD></TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>

> Any help would be appreciated. This is part of a
> large sed script but this last bit is just a
> little bit tricky.

I should also add that these lines may be *y formatted ie.
multiple spaces tabs \n's etc.

Thanks,
Doug

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

Sed matching lines ?

Post by Charles Dem » Thu, 04 May 2000 04:00:00





>> Hello all,

>> I'm trying to match this block of text at the end
>> of a file.

>>         </TABLE></TD></TR>
>> </TABLE>
>> </FORM>
>> </BODY>
>> </HTML>

>> there may possibly be blank lines at the end of
>> the file after </HTML> and
>> </TABLE></TD></TR>
>> </TABLE>
>> occurs multiple times earlier in the file.

>> I need to replace this text with

>>         </TABLE>
>> Some new test here.
>> </TD></TR>
>> </TABLE>
>> </FORM>
>> </BODY>
>> </HTML>

>> Any help would be appreciated. This is part of a
>> large sed script but this last bit is just a
>> little bit tricky.

>I should also add that these lines may be *y formatted ie.
>multiple spaces tabs \n's etc.

Then I suggest that you "strangely unformat" them first, getting rid
of the superfluous newlines, tabs, spaces, etc.

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.

 
 
 

1. inserting lines before and after lines with matching pattern using sed?

I need to go through a file and wherever I find lines that contain a
certain string I need to insert a line above and below that line.
Lines that don't contain the string can go straight into the new file.

I've been trying various sed commands to no avail.  Can this be done
with sed, or am I wasting my time and need to go at it a different
way?  If it can be done with sed, how?

Thanks,
Rob Eger

Tech-X Corporation
Boulder, CO

2. how to conf wintv from hauppauge

3. how do I tell SED to print only matching lines?

4. Remote openGL apps

5. SED - Mulitiple Line Matching/Saving

6. ctx1561 cannot go above 800x600!

7. SED question (1st line that matches expression)

8. Anyone try Qt?

9. How to replace a whole line (matching a pattern) in a text filke with SED ?

10. Pattern Matching Multiple Lines with SED and AWK

11. sed multiple line match

12. Q: del line above match with sed?

13. Find First Match Using SED and Then Extract Text from Line