亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 新手求助:如何在HP-UX下獲得前一日的日期 [打印本頁]

作者: marliuang    時間: 2006-06-14 00:09
標題: 新手求助:如何在HP-UX下獲得前一日的日期
date +'%m%d'  可以取到當前日期,格式為mmdd

但是我現(xiàn)在需要得到昨天的日期,格式仍為mmdd,請教高手如何實現(xiàn)?

一定需要寫shell才能實現(xiàn)的么?
作者: luodonghua    時間: 2006-06-14 09:13
貼出我的代碼的一部分

  1. # step 1, generate application statistics at the morning for yesterday
  2. get_one_day_before_specified_date()
  3. {
  4. #get the command line input(date month & year)
  5.     day=$1
  6.     month=$2
  7.     year=$3

  8.     # if it is the first day of the month
  9.     if [ $day -eq 01 ]
  10.     then
  11.         # if it is the first month of the year
  12.         if [ $month -eq 01 ]
  13.         then
  14.             # make the month as 12
  15.             month=12

  16.             # deduct the year by one
  17.             year=`expr $year - 1`
  18.         else
  19.             # deduct the month by one
  20.             month=`expr $month - 1`
  21.         fi
  22.          
  23.         # use cal command, discard blank lines,
  24.         # take last field of last line,   
  25.         # first awk  command is used to get the
  26.         # last useful line of the calendar cmd,
  27.         # second awk command is used to get the   
  28.         # last field of this last useful line,
  29.         # NF is no. of fields,
  30.         # $NF is value of last field

  31.                 day=`cal $month $year | awk 'NF != 0{ last = $0 }; END{ print last }' |  awk '{ print $NF }'`
  32.     else
  33.         # deduct the day by one
  34.         day=`expr $day - 1`
  35.     fi

  36.     # echo $month $day $year
  37.     year_2dig=`echo $year|awk '{print substr($0,3)}'`
  38.     echo $month/$day/$year_2dig
  39. }

  40. YEAR_T=`date +%Y`;
  41. MONTH_T=`date +%m`;
  42. DAY_T=`date +%d`;

  43. YESTERDAY=`get_one_day_before_specified_date $DAY_T $MONTH_T $YEAR_T`;

  44. # echo "===============${YESTERDAY}==================";
復制代碼

作者: luodonghua    時間: 2006-06-14 09:13
我的主機就是HP11i
作者: marliuang    時間: 2006-06-15 12:49
多些,我的主機也是11的。怎么說是貼出代碼的一部分,難道還有下文?
先試試看了。




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2