Register
It is currently Mon Dec 22, 2014 12:39 am

A really basic problem, but one that will help me leap ahead


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Oct 05, 2009 8:24 am   

Joined: Mon Oct 05, 2009 8:16 am
Posts: 1
I have a program that uses the program name "download", an option ( eg. --quick/ --slow/ --never ) and then takes an argument which is a number between 1 and 1000.
The number refers to a file.

The purpose of the program is to download from the internet a particular file.

My problem is that when I want to download a large number of files, I am writing out each particular file in it's own bash command.

for example, I am doing:

" download --quick 233 && download --quick 234 && download --quick 235 && download --quick 236 "

With very large numbers, this is very boring and time consuming to write the command.

How could I give bash a statement with the logic " download all the files between 232 and 237 " ?

Thanks in advance for your help.


Top
 Profile  
 PostPosted: Mon Oct 05, 2009 8:42 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Code:
for i in $(seq 233 237); do [ $? -eq 0 ] && download --quick $i; done


There's a one-liner, just change the numbers 233 and 237 to the range you want :)

If the previous one exited with a return status of 0 it will continue downloading, otherwise it'll just stop downloading :)

Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP