#!/usr/bin/ksh # AUTHOR: Xin23 # Version: Beta 0.1 # Date: 2014-09-05 Get_Days_From_1970(){ BEGINYEAR=1970 ENDYEAR=$(date +%Y) YEARNUM=$(($ENDYEAR-$BEGINYEAR)) LYEARNUM=$(($YEARNUM/4)) RNUM=${LYEARNUM%.*} DAYNUMY=$(($YEARNUM*365)) DAYNUMZ=$(($DAYNUMY+$RNUM)) DAYNUMA=$(($(date +%j)+$DAYNUMZ)) echo $DAYNUMA } Get_Days_From_1970
# 此函数用来获取1970.1.1至今的天数
执行如下:
[aybq76:root]#./1970.sh
16319
[aybq76:root]#date
Fri Sep 5 13:52:57 BEIST 2014
[aybq76:root]#
本文出自 “Xin23的流水账” 博客,请务必保留此出处http://xin23.blog.51cto.com/1827266/1549207
原文地址:http://xin23.blog.51cto.com/1827266/1549207