I have this text file (it's really a part of an html):
<tr>
<td width="10%" valign="top"><P>Name:</P></td>
<td colspan="2"><P>
XXXXX
</P></td>
</tr>
<tr>
<td width="10%" valign="top"><p>City:</p></td>
<td colspan="2"><p>
Mycity
</p></td>
</tr>
<tr>
<td width="10%" valign="top"><p>County:</p></td>
<td colspan="2"><p>
YYYYYY
</p></td>
</tr>
<tr>
<td width="10%" valign="top"><p>Map:</p></td>
<td colspan="2"><p>
ZZZZZZZZ
I've used this sed command to extract "Mycity"
$ tr -d '\n' < file.html | sed -n 's/.*City:<\/p><\/td>.*<p>\(.*\)<\/p><\/td>.*/\1/p'
The regular expression as far as I know works but I get
Map:
Instead of Mycity
.
I've tested the REGEX with Rubular and works but not with sed. Is sed not the right tool? What I¡m I doing wrong?
PS: I'm using Linux