bashwgetleading-zerobrace-expansion

How do you get missing leading 0 to show on wget request?


I am trying to use wget to download a sequence of files. This works well in curl but I like the ability to go easy on a server by spacing the calls and provide a wait of a few second between requests in wget. However, I'm having trouble with the ability to add leading zeros, which does not appear to work:

wget --wait=5 http://exampleurl.com/{001..102}0

The above command produces 404s because the leading 0 and 00 do not show up, such that it works essentially the same as {1..101}.

Just in case this was a problem with the old Bash version on my High Sierra OS X (Bash 3.2) I upgraded to Bash to 5.0.7. However even then, bash brackets doesn't appear to produce leading zeros as others report:

echo {01..30}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Any suggestions?


Solution

  • Despite my claim that I had upgraded Bash, the upgraded version was not actually being used for the commands. While asking for the bash version produces:

    bash --version
    GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin17.7.0)
    ...etc...
    

    However, as the user Cyrus suggested in his comment to my question, by entering:

    echo "$BASH_VERSION"
    

    showed that I was still running 3.2.

    The fix was to be found in the Terminal app Preferences for OS X. Where it says "Shell opens with:" in the box under "Command (complete path):" I supplied the path to the upgraded version of bash installed by home brew. Opening a new window now shows:

    echo "$BASH_VERSION"
    5.0.7(1)-release