Sunday, November 4, 2007

Downloading a bunch of files in unix

This article talks about how to download a bunch of files named sequentially:

1st Choice:

Use "curl"
for example:

curl -O http://www.jcedu.org/2/jq/dcd/mp3/[01-30].mp3

pay attention to the option "O" ,which means remote names. It will write output to local files with the same name as the remote files we get. Otherwise all data will be printed in the terminal, which means we will get nothing.

2nd Choice

Use "wget" by shell scripting
for example:

to get the same files as above, edit a script like this:

#!/bin/sh
for ((i=1;i<10;i++))
do wget http://www.jcedu.org/2/jq/dcd/mp3/0"$i".mp3
done
for ((i=10;i<31;i++))
do wget http://www.jcedu.org/2/jq/dcd/mp3/"$i".mp3
done
exit 0

No comments: