Note that there are some explanatory texts on larger screens.

plurals
  1. POOne more greedy sed question
    primarykey
    data
    text
    <p>I'm doing an automated download of a number of images using an html frame source. So fra, so good, Sed, wget. Example of the frame source:</p> <pre><code>&lt;td width="25%" align="center" valign="top"&gt;&lt;a href="images/display.htm?concept_Core.jpg"&gt;&lt;img border="1" src="t_core.gif" width="120" height="90"&gt;&lt;font size="1" face="Verdana"&gt;&lt;br&gt;Hyperspace Core&lt;br&gt;(Rob Cunningham)&lt;/font&gt;&lt;/a&gt;&lt;/td&gt; </code></pre> <p>So I do this:</p> <pre><code>sed -n -e 's/^.*htm?\(.*jpg\).*$/\1/p' concept.htm </code></pre> <p>to get the part which looks like this:</p> <pre><code>concept_Core.jpg </code></pre> <p>to do then this:</p> <p>wget --base=/some/url/concept_Core.jpg</p> <p>But there is one nasty line. That line, obvioulsy, is a bug in the site, or whatever it can be, but it is wrong, I can't change it, however. ;)</p> <pre><code>&lt;td width="25%" bla bla face="Verdana"&gt;&lt;a href="images/display.htm?concept_frigate16.jpg" target="_top"&gt;&lt;img bla bla href="images/concept_frigate16.jpg" target="_top"&gt;&lt;br&gt;Frigate 16&lt;br&gt; </code></pre> <p>That is, two of these "<strong>concept_Frigate16.jpg</strong>" in a line. And my script gives me</p> <pre><code>concept_frigate16.jpg" target="_top"&gt;&lt;img border="1" src="t_assaultfrigate.gif" width="120" height="90" alt="The '16' in the name may be a Sierra typo."&gt;&lt;/a&gt;&lt;a href="images/concept_frigate16.jpg </code></pre> <p>You understand why. Sed is greedy and this obviously shows up in this case.</p> <p><em>Now the question is, how do I get rid of this corner case? That is, make it non-greedy and make it stop on the FIRST <strong>.jpg?</em></strong><em>emphasized text</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload