Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the last day judgment of each month by SHELL script

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report