I would like to download a bunch of PDF with wget
in bash
(version 3.2.57(1)-release) on a Mac. The PDF represent old newspaper article, which have
Brace expansions don't know about other brace expansions. You can't have multiple brace expansions and have them change in tandem. Instead, you must use a for
loop.
for year in {10..16}; do
for month in `seq -w 1 12`; do
for day in `seq -w 1 31`; do
wget ... 453041671-18$year$month$day/453041671-18$year$month${day}_tif/jpegs/453041671-18$year$month$day.pdf
# The second day is in braces because otherwise it would parse as $day_tif.
done
done
done
In case you want to reduce the number of spawned wgets
, you can replace wget
with echo ... >> listing
, and then use the --input-file
(-i
) option to get wget
to pull URLs from that file.