|
发表于 2006-3-27 14:27:09
|
显示全部楼层
######判断昨天是哪一天#########
current_year=`date +%Y`
current_month=`date +%m`
current_date=`date +%d`
Fun_yesterday()
{
case "$current_month" in
01)
if(test "$current_date" -eq 1) then
handle_year=`expr $current_year - 1`
handle_month=12
handle_date=31
else
handle_year=$current_year
handle_month=$current_month
handle_date=`expr $current_date - 1`
if(test "$handle_date" -lt 10) then
handle_date=0$handle_date
fi
fi;;
02|04|06|08|09|11)
if(test "$current_date" -eq 1) then
handle_date=31
handle_month=`expr $current_month - 1`
if(test "$handle_month" -lt 10) then
handle_month=0$handle_month
fi
else
handle_date=`expr $current_date - 1`
if(test "$handle_date" -lt 10) then
handle_date=0$handle_date
fi
handle_month=$current_month
fi
handle_year=$current_year;;
03)
if(test "$current_date" -eq 1) then
value1=`expr $current_year % 4`
value2=`expr $current_year % 100`
value3=`expr $current_year % 400`
if(test "$value1" -eq 0 -a $value2 -ne 0 -o $value3 -eq 0) then
handle_date=29
else
handle_date=28
fi
handle_month=02
else
handle_date=`expr $current_date - 1`
if(test "$handle_date" -lt 10) then
handle_date=0$handle_date
fi
handle_month=$current_month
fi
handle_year=$current_year;;
05|07|10|12)
if(test "$current_date" -eq 1) then
handle_date=30
handle_month=`expr $current_month - 1`
if(test "$handle_month" -lt 10) then
handle_month=0$handle_month
fi
else
handle_date=`expr $current_date - 1`
if(test "$handle_date" -lt 10) then
handle_date=0$handle_date
fi
handle_month=$current_month
fi
handle_year=$current_year;;
*)
echo "ERROR1!";;
esac
if(test $# -eq 0) then
echo $handle_year$handle_month$handle_date
else
for argument in $*
do
case "$argument" in
y)
echo $handle_year;;
m)
echo $handle_month;;
d)
echo $handle_date;;
c)
echo $handle_year | cut -b3-4;;
*)
echo "ERROR2!";;
esac
shift
done
fi
}
Fun_echo_argument()
{
if(test "${1}" = "path") then
echo "${2}"
else #####"head"
echo "${3}"
fi
}
yy=`Fun_yesterday y`
mm=`Fun_yesterday m`
dd=`Fun_yesterday d`
month=$mm
day=$dd
########################################################################
v_time=`date +%Y%m%d%H%M`
###'----------------------'########## |
|