How to use grep to search blocks of lines ???
Posted on 2004-10-19
I want to build a script that can grab certain paramethers out of the xml-like tags. It is hard to explain without an example so, let me start with an example.
Let's say I have a file called xyz.html that contains:
<!-- <img src="\home\pics\2.gif">
<img src="\home\pics\5.gif"> -->
<!-- <img src="\home\pics\7.gif"> -->
Now I want to extract all the images that are within the comment tags (<!-- -->), in this case they'll be 2.gif, 3.gif, 4.gif, 5.gif and 7.gif. By using grep expression (such as : grep "<!--(.*)-->" *.*), I can easily extract 7.gif, but extracting images out of the commented block is a challenge. So is there a way to do this with grep or any other utilities?