Shell Scripting Help
Nils Kassube
kassube at gmx.net
Mon May 14 22:16:10 UTC 2007
chrisl at xp.etowns.net wrote:
> I have the following script:
>
> #!/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
> echo "1 day ago was: $MONTH $DAY6 $YEAR"
>
> The value DAY6 would be 13 if run today. If it was run on the 10th it
> would be 9.
>
> I need to have DAY6 displayed as 09 and not just 9, is this possible?
How about this one?
echo "1 day ago was: $(date -d yesterday '+%m %d %Y')"
Nils
More information about the ubuntu-users
mailing list