wget loop where numbers in URL stay the same

后端 未结 1 1281
闹比i
闹比i 2021-01-16 08:27

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

1条回答
  •  有刺的猬
    2021-01-16 09:07

    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.

    0 讨论(0)
提交回复
热议问题