For formatting a 3-digit integer (that is, 2 leading zeros for 1-9): printf %03d $i ... where $i is the number in question.
printf %03d $i