How do I do date math in a bash script on OS X Leopard?

后端 未结 8 941
迷失自我
迷失自我 2021-02-03 21:15

I realize I could whip up a little C or Ruby program to do this, but I want my script to have as few dependencies as possible.

Given that caveat, how does one d

8条回答
  •  广开言路
    2021-02-03 21:27

    For example, this OS X date command will add 14 days to the input string 20160826 (not the present time):

    date -j -f %Y%m%d -v+14d 20160826 +%Y%m%d
    

提交回复
热议问题