2011.02.25 19:37

Shell 전달날짜 구하기

#!/usr/local/bin/bash

YEAR=`date +%Y`
MONTH=`date +%m`

if [ $MONTH -eq 01 ]
then
    YEAR=`expr $YEAR - 1`;
    MONTH=12;
else
    MONTH=`expr $MONTH - 1`;
fi

if (( $MONTH < 10 ))
then
    MONTH=0$MONTH;
fi

CDATE=$YEAR$MONTH;

echo $CDATE;

Trackback 0 Comment 0