bash sequence 00 01 ... 10

Viewed 52280

in bash, with

$ echo {1..10}
1 2 3 4 5 6 7 8 9 10

I can get a numbers sequence, but in some case I need

01 02 03 ... 10

how I can get this ?

and how I can get ?

001 002 ... 010 011 .. 100
10 Answers
for i in {01..99}; do
  echo $i
done

will return :

01
02
03
04
05
06
07
08
09
10
...

Replacing 01 with 001 and 99 with 999 or 100 will do what you expect also.

echo 0{0..9}

You can get: 00 01 02 03 04 05 06 07 08 09

echo 0{0..9} 1{0..9}

You can get: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19

echo 00{0..9} 0{10..99}

You can get 001 .. 099

Related