On 2023-04-28 09:42, Per Jessen wrote:
Carlos E. R. wrote:
The problem is here:
cer@Isengard:~> grep -m 1 jpg /tmp/apod.html | sed -e 's/<//' -e 's/>//' -e 's/.*=//' -e 's/"//g' -e 's/^/http:\/\/apod.nasa.gov\/apod\//' http://apod.nasa.gov/apod/image/1602/Tarantula-HST-ESO-annotated1800.jpgArou... the Tarantula</a> cer@Isengard:~>
That sed "script" is an abomination.
:-D
Try this:
grep -m1 href.*jpg /tmp/apod.html |\ sed -e 's@^.*href="\([^"]\+\)".*$@http://apod.nasa.gov/apod/\1@'
For non-sed-speakers:
Given the one line of
<a href="image/1602/Tarantula-HST-ESO-annotated1800.jpg">Around the Tarantula</a
the translation is roughly - grab the text enclosed in double quotes and prepend the base url.
Yes, that is the intention, what I would want to do.
Combine it all into a one-liner (ignore the folding):
grep -m1 href.*jpg /tmp/apod.html |\ sed -e 's@^.*href="\([^"]\+\)".*$@http://apod.nasa.gov/apod/\1@' |\ wget -i -
Thanks :-) -- Cheers / Saludos, Carlos E. R. (from 15.4 x86_64 at Telcontar)