Print numbers with leading zeros in bash

For formatting a 3-digit integer (that is, 2 leading zeros for 1-9):

printf %03d $i

... where $i is the number in question.

Tags: