Reputation: 55972
I am trying to extract values from a file using a regular expresion.
I have 2 xml files. Each one is composed of lots of hotspots which has attributes X
and Y
, (coordinates), like:
<HOTSPOT ID="476" NAME="19.328" MEDIATYPE="url" MEDIA="/flash/hiddenHotspot.png" X="1427" Y="1989" WIDTH="280" HEIGHT="280" ZOOM="83" XSCALE="300" YSCALE="300" URL="/archive/manuscripts/1/decode?detail=476&page=0" URLTARGET="_self" ROLLOVER="0" CAPTION="328" TOOLTIP="">
<TOOLTIP><b>19.328</b>.<br><p class="poem1">In the Year 10 House, on the Day 11 Monkey,</p></TOOLTIP>
</HOTSPOT>
I am trying to extract just the X value from the file. I started with grep but it returns the full lines. My regex is just /X="([0-9]+)"/
. I am on ubuntu 12.04. I'm sure that one of these built in utilities can help but I have not been able to find which one.
Is there a way to just print to stdout the matches of my regex using a linux utility? Each match should be on a seperate line? Could someone please point me in the right direction? Ty.
Upvotes: 0
Views: 521