Tag: Date
####################################################################### Copyright C # # All rights Reserved # # Name : yestoday.sh# Author:canux [email protected] # # version:v1.0 # time:wed (04:37:37 PM cst# Description : ########################################################################!/bin/bashif ["$" = ""]then DATE_NO= " Date +%y%m%d ' curday= ' date +%d ' curmonth= ' date +%m ' curyear= ' date +%y ' else date_no=$1 curyear= ' echo $ | awk ' {print substr ($0,1,4)} ' Curmonth= ' echo $ | awk ' {print substr ($0,5,2)} ' curday= ' echo $ | awk ' {print substr ($0,7,2)} ' filastyear= ' expr $CURYEAR-1 ' If [[$ (10# $CURMONTH)]-eq 1]]then lastmonth=12else lastmonth = ' Expr $CURMONTH-1 ' fiif [[$LASTMONTH-ge 1]] && [[$LASTMONTH-le 9]]then lastmonth=0$lastmonthelse Lastmonth = $LASTMONTHfiNUM 1= ' cal $LASTMONTH $CURYEAR | awk ' Nr==6{print $NF} ' num2= ' cal $LASTMONTH $CURYEAR | awk ' Nr==7{print $NF} ' num3= ' cal $LASTMONTH $CURYEAR | awk ' Nr==8{print $NF} ' if [[$NUM 3-ne 0]]Then lmlastday= $NUM 3elif [[$NUM 3-eq 0]] && [[$NUM 2-ne 0]]then lmlastday= $NUM 2else lmlastday= $NUM 1fiif [[$ ( 10# $CURDAY))-eq 1]] then if [[$ ((10# $CURMONTH))-eq 1] "then lastdate= $LASTYEAR $lastmonth$lmlastday Else lastdate= $CUR Year$lastmonth$lmlastday fielse lastdate= ' expr $DATE _no-1 ' Fiecho $LASTDATE ######################################## ############################### Copyright C # # All rights Reserved # # name:tomorrow.sh# Author:canux [EMAIL PR Otected] # # version:v1.0 # time:wed 04:52:14 PM cst# Description: ######################################### ###############################!/bin/bashif ["$ $" = ""]then curdate= ' date +%y%m%d ' curday= ' date +%d ' curmonth= ' date +%m ' curyear= ' date +%y ' curhour= ' date +%h ' curmin= ' date +%m ' else curdate=$8 curyear= ' echo $ | awk ' {print substr ($0,1,4)} ' curmonth= ' echo | awk ' {print substr ($0,endhour,2)} ' curday= ' echo | awk ' {print substr ($0,7,2)} ' finextyear= ' expr $CURYEAR + 1 ' if [[$ (10# $CURMONTH))-eq]]then nextmonth=1else nextmonth= ' expr $CURMONTH + 1 ' fiif [[$ ((10# $NEXTMONTH))-ge 1]] && [[$ (10# $N Extmonth))-le 9]]then nextmonth=0$ ((10# $NEXTMONTH)) Else nextmonth= $NEXTMONTHfi #the last day of curent monthnum1= ' Cal $C Urmonth $CURYEAR | awk ' Nr==6{print $NF} ' num2= ' cal $CURMONTH $CURYEAR | awk ' Nr==7{print $NF} ' num3= ' cal $CURMONTH $CURYEAR | awk ' Nr==8{print $NF} ' if [[$NUM 3-ne 0]]then lastday= $NUM 3elif [[$NUM 3-eq 0]] && [[$NUM 2-ne 0]]then lastd ay= $NUM 2else lastday= $NUM 1fiif [[$ ((10# $CURMONTH)-eq]] && [[$ ((10# $CURDAY))-eq]]then nextdate=${nexty Ear}0101elif [[$ ((10# $CURDAY))-eq $ ((10# $LASTDAY))]]then nextdate=${curyear}${nextmonth}01else nextdate= ' expr $ Curdate + 1 ' fiecho $NEXTDATE
Shell:bash gets the day before and after date based on the specified date