From: John Kelly (john at domain frontend.ie)
Date: Mon 13 Aug 2001 - 16:19:00 IST
On Mon, Aug 13, 2001 at 04:14:59PM +0100, Will Mernagh wrote:
> Hi,
>
> I have the following in a script
>
> DAYa=`date | awk '{print $3}'`
> DAYb=`expr $DAYa - 1`
> MONTH=`date '+%m'`
> YEAR=`date | awk '{print $6}'`
> DATEa=$DAYa'-'$MONTH'-'$YEAR
> DATEb=$DAYb'-'$MONTH'-'$YEAR
>
>
> This returns the following for DATEa 13-08-2001
> DATEb 12-08-2001
>
> How can I change the month from 08 to 8. I was thinking of using ${MONTH/0/}
> which would do the trick but if the MONTH is 10, 20, 30 etc. I will get 1,
> 2, 3 etc. So any ideas? and before all of you replying saying the month
> can't be 20 or 30, I know but I have the same problem for $DAYa so there.
What about a quick IF?
DAYa=`date | awk '{print $3}'`
DAYb=`expr $DAYa - 1`
MONTH=`date '+%m'`
YEAR=`date | awk '{print $6}'`
if [ "$MONTH" = "10" ]; then
:
else
MONTH=${MONTH/0/}
fi
DATEa=$DAYa'-'$MONTH'-'$YEAR
DATEb=$DAYb'-'$MONTH'-'$YEAR
?
- John
--- www.fuckcuntandbollocks.com
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:11:35 GMT