Date arithmetic in Unix shell scripts

前端 未结 14 1659
生来不讨喜
生来不讨喜 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 23:00

    date --date='1 days ago' '+%a'
    

    It's not a very compatible solution. It will work only in Linux. At least, it didn't worked in Aix and Solaris.

    It works in RHEL:

    date --date='1 days ago' '+%Y%m%d'
    20080807
    

提交回复
热议问题