2011-11-28 57 views
1

我试图让身体标记 这里仅之间的内容就是一个例子文件grep的删除head标签

<html> 
<head> 
<tite> 
Test1 
</title> 
</head> 
<body> 
Hello World! 
</body> 
</html> 

我试图

grep "\<body\>.*\<\/body\>" index.html 

,但它只是没有返回值(做-v回报整个事情,以确保其正确的文件)。

感谢

+2

http://stackoverflow.com/a/1732454/1043165 – Martijn

+0

什么是您尝试确切说法?什么是index.html?你的意思是index.html的来源? –

+0

对不起,缩进错误。我使用grep“\ 。* \ <\/body\>”index.html 其中index.html是我放置的示例文件(与test1和hello世界!) – Kamran224

回答

4

不能为多模式匹配使用grep。使用awk代替:

awk '/<body>/,/<\/body>/' index.html 

返回结果:

<body> 
Hello World! 
</body>