2014-02-20 54 views
0

我有一個包含html代碼的日誌文件,我需要刪除這個文件中每個可能匹配的html標籤之間的所有內容。這怎麼可能使用過濾器?我的文件從SHELL中的日誌文件中刪除HTML代碼

例子:

some text here 
<html> 
code 
</html> 
some text there 
<html> 
code 
</html> 
some other text 

輸出應該是:

some text here 
some text there 
some other text 

回答

1

awk應該做的:

awk '/<html>/{f=1;next} !f; /<\/html>/{f=0}' file 
some text here 
some text there 
some other text 
1

爲什麼不乾脆:

sed '/<html>/,/<\/html>/d' 

它適用於您的示例。