HTMLファイルのコメントタグを削除したい。
<!--- <script save and execute me> -->
になる必要があります:
<script save and execute me>
私は試した
sed -i s_^<!-- \(.*\) -->$_\1_ text.sed
しかし、<と>は読み出し/読み出し文字と見なされるため、失敗します。私は試したより:
sed -i 's_^<!-- \(.*\) -->$_\1_' text.sed
しかし、\ 1よりも評価されるべきではありません。うまくいけば、ここの誰かがアイデアを持っていますか?
以下を含むファイルtest.htmlを指定します。
<html>
<!--- <script save and execute me> -->
</html>
コマンド:
sed -e "s/<!---* *<\(.*\)> *-->/<\1>/" test.html
放出:
<html>
<script save and execute me>
</html>
これも変換されることに注意してください。
<html>
<!-- some info explaining why we have commented out the following -->
<!-- <hr> -->
<!--- <script save and execute me> -->
</html>
に:
<html>
<!-- some info explaining why we have commented out the following -->
<hr>
<script save and execute me>
</html>