What's the simplest way to increment the number 0000 up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0?
Thanks! jlc
On Wed, 9 Jul 2008, Joseph L. Casale wrote:
What's the simplest way to increment the number 0000 up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0?
In zsh, it would be something like:
for i in {0000..9999}; do echo $i done
-steve
On Wed, Jul 9, 2008 at 6:22 PM, Joseph L. Casale JCasale@activenetwerx.com wrote:
What's the simplest way to increment the number 0000 up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0?
Your homework done in a snap!
for (i=0; i<1000;i++); do printf "%04d\n" i done
Thanks! jlc _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
What's the simplest way to increment the number 0000 up by one until some other 4 digit number while preserving leading zero's until the 1000's has a digit other than 0?
Lots of answers, depending on the shell. I like this version for ksh:
typeset -Z4 a=-1 while (( a++ < 1000 )) do print $a done
Not enough use is made of typeset :-)