- 论坛徽章:
- 1
|
如何对文件内容以块儿的形式操作-请高手指点
/home/lee#cat file
<VirtualHost 1.2.3.4>
ServerName fox.com
................
.................
</VirtualHost>
<VirtualHost 5.2.3.4>
ServerName dog.com
................
.................
</VirtualHost>
<VirtualHost 1.2.3.4>
ServerName pig.com
................
.................
</VirtualHost>
<VirtualHost 2.2.3.4>
ServerName ddd.com
................
.................
</VirtualHost>
/home/lee#awk 'BEGIN{RS=ORS=""}$0!~/fox\.com/{print $0,"\n\n"}' file
<VirtualHost 5.2.3.4>
ServerName dog.com
................
.................
</VirtualHost>
<VirtualHost 1.2.3.4>
ServerName pig.com
................
.................
</VirtualHost>
<VirtualHost 2.2.3.4>
ServerName ddd.com
................
.................
</VirtualHost>
/home/lee# |
|