Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

im looking to only grab images from a document with a certain path for example

domain.com/uploads/287167/file_name.jpg

only grab those with the uploads/number/filename

im currently doing it this way

wget http://domain.com/news/36843 -q -O - | sed -n -e"s%^.*\(http://site.com/uploads/[0-9][^ \"\']*\.jpg\).*$%\1%p" | xargs wget -q

any other ways of doing this?

thanks in advance

share|improve this question
    
You could replace wget with curl, that's another way of doing it. Are you looking for a list of alternative operations? That could be quite long. –  Tim Aug 15 '12 at 19:32
    
@chrismccoy Look at -A/-R options. They're comma-separated lists of file name suffixes or patterns to accept or reject. Note that if any of the wildcard characters, *, ?, [ or ], appear in an element of acclist or rejlist, it will be treated as a pattern, rather than a suffix. –  rush Aug 15 '12 at 20:36
    
can the -A allow for paths only uploads/ etc –  chris mccoy Aug 15 '12 at 21:33
add comment

1 Answer

It would be a little easier to do this:

wget http://domain.com/news/36843 -q -O - \
  | grep -Eo 'http://site.com/uploads/[0-9]+/[^"]+\.jpg' \
  | wget -i -

As to -A, you can filter jpg files. To filter the path you'd need -I. But it works in recursive mode only so it may download more than you want:

wget http://domain.com/news/36843 -r --level 1 -A jpg -I "/uploads/[0-9]*"

Untested.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.