Wednesday, November 28, 2012

Shell script: format numbers


Shell script to format date in yyyy.mm.dd format
#!/bin/bash

year=2012

for (( c=1; c<=12; c++ ))
do
   month=$(printf "%02d" $c)

  for (( d=1; d<=15; d++ ))
  do
     day=$(printf "%02d" $d)
     echo $year.$month.$day
  done
done

No comments: