换了个思路,改做了个计算昨天.明天日期的小脚本,在很多地方可以当用函数用到的..请各位拍拍砖哈...
[quote]#!/bin/ksh
#计算昨天.明天日期的脚本 V051129
#四川省乐山市沙湾区邮政局 宋涛
dd=$(date +%d)
mm=$(date +%m)
yy=$(date +%Y)
while :
do
[ $dd = "01" -a $mm = "01" ] && \
{
yesterday=$((yy-1))1231
tomorrow=${yy}0102
break
}
[ $dd = "31" -a $mm = "12" ] && \
{
yesterday=${yy}1230
tomorrow=$((yy+1))0101
break
}
[ $dd = "01" ] && \
{
yesterday=${yy}$((mm-1))$(cal $((mm-1)) $yy |xargs|awk '{print $NF}')
tomorrow=${yy}${mm}02
break
}
[ $dd = "$(cal $mm $yy |xargs|awk '{print $NF}')" ] && \
{
yesterday=${yy}${mm}$((dd-1))
tomorrow=${yy}$((mm+1))01
break
}
yesterday=${yy}${mm}$(printf "%02d" $((dd-1)))
tomorrow=${yy}${mm}$(printf "%02d" $((dd+1)))
break
done
echo " yesterday = $yesterday\n tomorrow = $tomorrow"[/quote]
|
|
|