I’m writing a bash script that will download the page then search for a jpg links and will download them. I’m stucked with grep/sed commands, can’t make them find the links. So far I’ve tried:
grep -e "http.*" -e ".*jpg" -n wget.html
and
sed -n '/http/,/jpg/p' wget.html
How can I search from http:// to jpg in linux? Or maybe there’s another way other than sed,grep?
As I understand it, you want to extract all http://…jpg strings from some downloaded HTML. I guess ideally one per line.
The grep picks out only lines that contain http refs, the sed strips out all other junk from those lines.
This is limited to one http ref per HTML line. If that can’t be assumed, you could add something like “tr ‘>’ ‘\010’ at the beginning of the pipeline to split up lines with multiple tags.
Example: