#!/bin/sh
#昨天日期shell版
yy=`date +%Y`;mm=`date +%m`;dd=`date +%d`
d0=`echo "$dd"|awk '{printf"%02d\n",$1-1}'`
m0=`echo "$mm"|awk '{printf"%02d\n",$1-1}'`
y0=`echo "$yy"|awk '{printf"%02d\n",$1-1}'`
case $d0 in
00) if [ $m0 = 00 ]; then
ym=`cal 12 $y0|xargs|awk '{print $NF}'`
y0=$y0;m0=12;d0=$ym
else
ym=`cal $m0 $yy|xargs|awk '{print $NF}'`
d0=$ym;m0=$m0;y0=$yy
fi
;;
*) d0=$d0;m0=$mm;y0=$yy;;
esac
echo "$y0$m0$d0"
阅读(2246) | 评论(2) | 转发(0) |