Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pattern Matching Multiple Lines with SED and AWK

4 views
Skip to first unread message

Chris Gray

unread,
Oct 4, 1998, 3:00:00 AM10/4/98
to
Okay, so I've read all of the guides on using SED and AWK and have been
successful in writing scripts to replace text in a line in multiple files.
However, I have had no luck finding out how to pattern match on mutliple
lines and then make a change. Here's my problem, I need to add

<!--

before the following lines of code:

<CENTER><TABLE BORDER=0><TR><TH>
<div align="center"><center>
<table border="2" cellpadding="0" cellspacing="0">
<tr>
<td><CENTER>


and add

-->

after:

</td>
</tr>
</table>
</center></div>
</TH></TR></TABLE></CENTER>
<P>

I've got this in hundreds of files and really don't want to edit each one by
hand. So, if you know of a solution please let me know. Also, I've read
through about 12 guides to SED and AWK and haven't found anything dealing
with pattern matching MULTIPLE lines. Is there some escape character that
SED and AWK use to recognize a new line?

chris...


Chris Gray

unread,
Oct 4, 1998, 3:00:00 AM10/4/98
to
sorry, wrong group. meant comp.unix.questions.

Mike Miller

unread,
Oct 9, 1998, 3:00:00 AM10/9/98
to
"Chris Gray" <ch...@ni3d.com> wrote:

>Okay, so I've read all of the guides on using SED and AWK and have been
>successful in writing scripts to replace text in a line in multiple files.
>However, I have had no luck finding out how to pattern match on mutliple
>lines and then make a change. Here's my problem, I need to add
>

>chris...
>
There's a script on pages 64 & 65 in the Sed and Awk book that will do
what you want. The idea is to use more than one line to do the
matching. Use one line for each pattern if needed.
Mike

Mike Miller

unread,
Oct 9, 1998, 3:00:00 AM10/9/98
to
0 new messages