问题
I am trying to wget files from a range of URLs. Following is my bash script
for i in {1..171}
do
wget --mirror --random-wait -R gif,jpg,pdf "http://www.example.com/member/members-directory/?mode=paging&Keyword=&Type=&pg="$i
done
It is just downloading one page.
But I am getting to see on my terminal that
Last-modified header missing -- time-stamps turned off.
2013-11-16 11:56:06 (34.2 KB/s) - `www.example.com/member/members-directory/index.html?mode=paging&Keyword=&Type=&pg={1..171}' saved [31073]
But as output all I got is one page.
回答1:
Let me guess, it's downloading only the page http://www.example.com/member/members-directory/?mode=paging&Keyword=&Type=&pg={1..171}
? That is, not expanding {1..171}
correctly.
Keep in mind that the {N..M}
style sequence generation only works in bash, typically not in sh. So if the shebang of your script is #!/bin/sh
try changing it to #!/bin/bash
.
来源:https://stackoverflow.com/questions/20015611/loop-of-form-for-i-in-1-171-not-working-only-loops-once-with-i-1-171