When I run the following command in linux:
wget http://page.com/{0000..0100}.jpg
he tries to download the following sequence:
...
that is, it does not place the zeros.
When I run the following command in linux:
wget http://page.com/{0000..0100}.jpg
he tries to download the following sequence:
...
that is, it does not place the zeros.
The bash expansion isn't going to pad teh numbers to use mathematically insignificant zeros. You can use seq
with the -w
(width) option to pad with leading zeros.
for i in `seq -w 1 1000`
do
wget http://example.com/path/to/$i.jpg
done
Consider upgrading Bash. Your code works on Bash4+:
$ echo $BASH_VERSION {001..003}
4.4.19(1)-release 001 002 003
but not on older versions like Bash 3.x:
$ echo $BASH_VERSION {001..003}
3.2.57(1)-release 1 2 3
If you're unable to upgrade, you can use printf
as a workaround:
wget $(printf "http://page.com/%04d.jpg\n" {1..100})