busybox date 日期增加一天明天 网上都是减一天 昨天

#!/bin/bash  
  
  

y_begin=$1
m_begin=$2
d_begin=$3
y_end=$4
m_end=$5
d_end=$6

echo $y_begin $m_begin $d_begin 
echo $y_end $m_end $d_end 

tmp=""
tomorrowday=""

begin="$y_begin$m_begin$d_begin" 
echo $begin
end="$y_end$m_end$d_end" 
echo $end


year=$y_begin
month=$m_begin
day=$d_begin
echo ${year} ${month} ${day}

fun_next_day()
{
	
	#echo "---${year} ${month} ${day}"
	
	if [[ "$day" == "31" ]];then 
	    if [[ "$month" == "12" ]];then 
	    	day="01"
	    	month="01"
	        year=`expr $year + 1`
	    elif [[ "$month" == "01" || "$month" == "03" ||  "$month" == "05" || "$month" == "07" || "$month" == "08" || "$month" == "10" ]];then	        
	        day="01"  
	        month=`expr ${month} + 1`
	        month=$(printf "%02d" "$month")
	    fi
	elif [[ "$day" == "30" ]];then 
		#echo "--30-----"
		if [[ "$month" == "04" || "$month" == "06" || "$month" == "09" || "$month" == "11" ]];then 
			#echo "--31-----" 		        
		        day="01"
		        month=`expr ${month} + 1`
		        month=$(printf "%02d" "$month")
		else
			#echo "--32-----" 
			day=`expr $day + 1`
			day=$(printf "%02d" "$day")
			#echo "day------$day"		
		fi
	elif [[ "$day" == "29" && "$month" == "02" ]];then            
	        day="01" 
	        month=`expr ${month} + 1` 
	        month=$(printf "%02d" "$month")
	        tomorrowday="${year}${month}${day}"
	elif [[ "$day" == "28" && "$month" == "02" ]];then 
	        year_type=`expr ${year} % 4`
	        if [[ "$year_type" == "0" ]];then   
	        	day=`expr $day + 1`
	        	day=$(printf "%02d" "$day")
	        else
	        	day="01"  
	        	month=`expr ${month} + 1`
	        	month=$(printf "%02d" "$month")
	        fi
		         
	else
		day=`expr $day + 1`
		day=$(printf "%02d" "$day")
		#echo "day---$day"	    
	fi
	
	tomorrowday="${year}${month}$day"
	echo $tomorrowday
	#echo "end ---${year} ${month} ${day}"	
	
	#return $tomorrowday
}




echo "----------begin------"
echo $end
while [ "$begin" != "$end" ]
do
echo "begin--- $begin"
cp -rvf 20200509  $begin
fun_next_day  
begin=$tomorrowday

#sleep 1
done

你可能感兴趣的:(linux,order)