谁能帮我修改 sun solaris 中匹配模式之前的行,即搜索模式并将上面的行替换为其他文本。例如:在输入文件中:
<td>
Completed
</td>
需要的输出:
<td bgcolor = 'green'>
Completed
</td>
应首先搜索“已完成”模式,然后将上面的行替换为其他文本。以下是我使用过但未能得到结果的命令,
sed 's/<td>\nCompleted/<td>Completed/' exp12.html > sample.html
sed 's/<td>$Completed/<td>Completed/' exp12.html > sample.html
tr '\n' '*' exp12.html > sample.html
通过这个,所有的文本都变成了一行,然后使用了这个
sed '/<td>*Completed*/<td bgcolor = 'green'>*Completed*/' exp12.html > sample.html
请为我提供一个可以获取上述输出的 sun solaris 命令。