sun solaris で一致するパターンの前の行を変更するのを手伝ってくれる人はいますか。つまり、パターンを検索して、上の行を他のテキストに置き換えます。例: 入力ファイル内:
<td>
Completed
</td>
必要な出力:
<td bgcolor = 'green'>
Completed
</td>
パターン「Completed」を最初に検索してから、すぐ上の行を他のテキストに置き換える必要があります。以下は、私が使用して結果を取得できなかったコマンドです。
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
これにより、すべてのテキストが1行になり、これを使用しました
sed '/<td>*Completed*/<td bgcolor = 'green'>*Completed*/' exp12.html > sample.html
上記の出力を取得できる sun solaris コマンドを教えてください。