for example
input.txt:<html>
<body>
<pre class="hello">
<p>Paragrapg</p>
<p>Another paragraph two</p>
</pre>
</body>
</html>Run this command:awk "/pre class/,/two/" input.txtOutput will be:<pre class="hello">
<p>Paragrapg</p>
<p>Another paragraph two</p>To save output in another file use:awk "/pre class/,/two/" input.txt > outputIf you want to capture full html tag you have to know that / in awk should be writed as \/ and " should be writed as a triple """:awk "/<pre class="""hello""">/,/<\/pre>/"and now we capture full html tag:<html>
<body>
<pre class="hello">
<p>Paragrapg</p>
<p>Another paragraph two</p>
</pre>
</body>
</html>Here is awk utility:
No comments:
Post a Comment