bash single to double digit conversion

From thelinuxwiki
Revision as of 23:39, 10 May 2013 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

method using printf...

for i in {1..12}; 
do
  i=`printf "%02d" $i`
  echo $i
done

output

01
02
03
04
05
06
07
08
09
10
11
12