Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I write a bash script that is going to do the following:

URL = "example.com/imageID="
while (1..100)
   wget URL + $i #it will wget example.com/imageID=1, than 2, than 3 and so on
done

So I have a number of loops to perform, a URL which is ended with a number from the loop. I need to wget all of these.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

if you are using Bash 4.0, you can do this:

wget example.com/imageId={1..100}.jpg
share|improve this answer
add comment

It's fairly easy, even for someone with not much programming experience. When in doubt always read the Bash manual:

for i in {1..100}
do
    wget "example.com/imageID="$i
done
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.