How to realize the last day judgment of each month by SHELL script
This article mainly introduces the SHELL script how to achieve the last day of each month judgment, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
#! / bin/bash
# function definition
Function monBigorSmall ()
{
Big_month= (1 3 5 7 8 10 12)
Small_month= (4 6 9 11)
Year=$ (echo $1 | cut-c 1-4)
Month=$ (echo $1 | cut-c 5-6)
Day=$ (echo $1 | cut-c 7-8)
For bvar in ${big_month [@]}
Do
If [$bvar-eq $month]
Then
Echo 31
Fi
Done
For svar in ${small_month [@]}
Do
If [$svar-eq $month]
Then
Echo 30
Fi
Done
Iyear=$ ((10 million ${year}))
Imonth=$ ((10 million ${month}))
If [$imonth-eq 2]
Then
If [$(($iyear% 4))-eq 0-a $(($iyear% 100))-ne 0] | | [$(($iyear% 4))-eq 0]
Then
Echo 29
Else
Echo 28
Fi
Fi
}
#
Echo "#"
For ((ii=1;ii