Using seq to zero-pad strings in a series

Posted by hank, Sat May 19 04:06:00 UTC 2007

I thought this was pretty cool:

for i in `seq -f "%03g" 1 100`; do wget http://www.gozerog.com/images/Hawking_$i.jpg; done

We were trying to do this the other night using bash, but to no avail since the square brackets only work for local file path expansion. I should have remembered seq. Also, this example shows how to 0-pad a series using seq and bash, noted by the *-f* option. Three cheers for seq!

Tags:

Comments

  • no avatar available for Josh Josh
    May 23, 2007 @ 12:55 PM

    :) Good work! Easy and nice

Have your say

A name is required. You may use Markdown in your comments.