我正在处理一些html代码,并且遇到了一些问题。下面是一些代码提取物和格式完全相同如何在匹配模式之前使用sed插入一行
<tr>
<td nowrap valign="top" class="table_1row"><a name="d071301" id="d071301"></a>13-Jul-2011</td>
<td width="21%" valign="top" class="table_1row"><a href="http://www.info.htm" target="_blank">LCQ8: Personal data of job</a></td>
在这里,我不得不配合
<tr>
<td nowrap valign="top"
和<tr>
发生。问题前插入的东西,因为我有匹配模式在不同的路线。 我试图
grep -c "<tr>\n<td nowrap valign="top"" test.html
grep -c "<tr>\n*<td nowrap valign="top"" test.html
grep -c "<tr>*<td nowrap valign="top"" test.html
测试,但他们都不works.So我有两个维度,找出问题:
- 比赛
<td nowrap valign="top" and insert in the line above
- 匹配整个字符串
<tr>
<td nowrap valign="top"
有人会提出一种方法来做到这一点吗?
[希望这类似的问题,我之前提出可以帮你] [1] [1]:http://stackoverflow.com/如果您想了解更多的sed请参见本手册question/6624199/how-can-i-append-a-string-into-the-first-occurrence of-a-pattern –
also http://stackoverflow.com/q/6732702/7552 –