Bash loop over left padded numbers

Published on:

So if you have something that needs to loop over a list of left padded numbers like this.

01
02
03
04

You can do this.

for i in $(seq -f "%02g" 1 4); do
  echo ${i}
done