Date arithmetic in Unix shell scripts

前端 未结 14 1669
生来不讨喜
生来不讨喜 2020-11-27 22:29

I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs.

I\'m using a function to increment a day and another

14条回答
  •  悲哀的现实
    2020-11-27 22:38

    Looking into it further, I think you can simply use date. I've tried the following on OpenBSD: I took the date of Feb. 29th 2008 and a random hour (in the form of 080229301535) and added +1 to the day part, like so:

    $ date -j 0802301535
    Sat Mar  1 15:35:00 EST 2008
    

    As you can see, date formatted the time correctly...

    HTH

提交回复
热议问题