Shell Scripting Help

Matthew Flaschen matthew.flaschen at gatech.edu
Mon May 14 21:38:36 UTC 2007


chrisl at xp.etowns.net wrote:
> I need to have DAY6 displayed as 09 and not just 9, is this possible? 

Looks like just:

#!/usr/bin/ksh
CURRMONTH=`date +%m`
date '+%m %d %Y' |
{
read MONTH DAY YEAR
DAY6=`expr "$DAY" - 1`
case "$DAY6" in
0)
MONTH=`expr "$MONTH" - 1`
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY6=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
esac
}

if [ ${#DAY6} == 1 ]; then
    DAY6=0$DAY6
fi

echo "1 day ago was: $MONTH $DAY6 $YEAR"




More information about the ubuntu-users mailing list