Search This Blog

Tuesday, July 6, 2010

In bash, how could I add integers with leading zeroes and maintain a specified buffer.

Programmer Question

For example, I want to count from 001 to 100. Meaning the zero buffer would start off with 2, 1, then eventually 0 when it reaches 100 or more.



ex:
001
002
...
010
011
...
098
099
100



I could do this if the numbers had a predefined number of zeroes with printf "%02d" $i. But that's static and not dynamic and would not work in my example.



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails