|
Date and string functions are not terribly
easy in Unix, and generally involve parsing cal. So, if you want to do sysdate-1, what
you would do is this: DAY=`date +%d` MONTH=`date +%m` YEAR=`date +%C%y` echo $DAY $MONTH $YEAR if [ $DAY = 1 ] ; then if
[ $MONTH = 1 ] ; then
CAL_MONTH=12
CAL_YEAR=`expr $YEAR - 1` else
CAL_MONTH=`expr $MONTH - 1`
CAL_YEAR=$YEAR fi CAL_DAY=`cal $CAL_MONTH $CAL_YEAR|tail -2|head -1|awk '{print $NF}'` else CAL_DAY=`expr
$DAY - 1` CAL_MONTH=$MONTH CAL_YEAR=$YEAR fi echo "Yesterday was $CAL_MONTH $CAL_DAY $CAL_YEAR" or, you could do this: sqlplus << EOF spool date select sysdate-1 from dual; exit EOF grep -v SQL date.lst|tail -2|head -1 Whichever. HTH, Bambi. -----Original Message----- Hi, So if my date is 3/1/2002 I will get 2/28/20002.
TIA Yuval. |
Title: Unix shell Question
- Unix shell Question Yuval Arnon
- Re: Unix shell Question Bellows, Bambi
- Re: Unix shell Question lembark
- RE: Unix shell Question Ji, Richard
- RE: Unix shell Question Sakthi , Raj
