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

后端 未结 8 1000
迷失自我
迷失自我 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:26

    Because MacOS is based on BSD, not linux, the command is actually:

    date -v-1d
    

    The adjust switch takes the format -v[+/-](number)[ymwdHMS].

提交回复
热议问题