2

How can download all urls to follow a format like as www.site.com/fooXXX when XXX could be any number between 0-999, its posible?

5

You can simply use Bash's range syntax to specify the URL:

wget 'http://www.example.com/foo'{0..999}

This would be equal to the command written out like this (leaving most of the URLs in between out, because I'm too lazy to type 1000 URLs):

wget 'http://www.example.com/foo0' 'http://www.example.com/foo1' ... 'http://www.example.com/foo42' ... 'http://www.example.com/foo999'
  • 2
    If you need leading zeros: printf "http://www.example.com/foo%03d\n" {0..999} | xargs wget – Scott Deagan Sep 29 '16 at 14:29
  • 2
    @ScottDeagan or simply wget 'http://www.example.com/foo'{0..9}{0..9}{0..9} – Byte Commander Sep 29 '16 at 14:31
  • That's awesome! I've learnt something new today - thanks. – Scott Deagan Sep 29 '16 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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